简体   繁体   中英

Clear android application data programmatically

Manually I can do

Settings -> Applications -> Manage applications -> (choose my app) -> Clear data

How do I do this programmatically?

I need to delete all data, including those in shared preferences (, and variables).

Everything in your application is stored here /data/data/com.example.applicationpackagename/ .

Your application is run by a user which has R/W access on this directory.

You just need to remove every files in it.

For information : Android - How to delete a whole folder and content?

You could use following code in which "packagename" could be your application package name like com.example.app1

Intent intent = new Intent();
intent.setData(Uri.parse("package:" + packageName));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM