How to Clear User Data in your Android Application programmatically

How to clear user data of your application programmatically? Here I share you my solution how to do this.

You also can clear your user data by clicking “Clear Data” button in Settings–>Applications–>Manage Aplications–> YOUR APPLICATION
Application Info Android Dialog

To do it programmatically you need to remove user data from application dir.

Below you can download source code of sample Android project.

Pay attention in MyApplication class:

Download it from github

20 Replies to “How to Clear User Data in your Android Application programmatically”

  1. Thanks for this informative post. I’m using Android and using “Clear Data” to clear user data. But programmatically option is new to me and I’ll try it on. 🙂

  2. Cool buddy!! I’m following exactly same way you describe to clear my Android user data. It’s really good and thanks for informative info.

  3. I Was used this code in my personal code but data is not cleared properly some data is not cleared when i checked in settings->application->manage application->app_name.
    Every time near about 4 kb data is remaining ,idon’t know why?
    please help……………….

  4. Thanks , I’ve been looking for this exactly .

    It comes very useful when performing clean-ups on Android JUnit Test.

    Thanks again 😀

  5. Hi Igor,

    thank you for this very informative post. I was searching for a way to clear the app data programmatically and you give me the solution 😉

  6. is there a way to clear the data programatically, but leave out shared preferences untouched? thanks in advance

  7. Hi,

    is there any way to clear other applications app data or uninstall app silently ….i dont want clear my current app data ,need to clear other app data…

    1. Hi sreelal,
      I think this is impossible to make clear data or remove other application without special permissions.
      I know about some special relations between application which signed with same certificate.

Leave a Reply

Your email address will not be published. Required fields are marked *