Clear android application data programmatically

4k views Asked by At

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).

2

There are 2 answers

6
AudioBubble On

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?

0
Sagar Date On

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));