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

19 thoughts on “How to Clear User Data in your Android Application programmatically

  • By Mark waugh - Reply

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

  • By Remote Data Centre - Reply

    Oh this is sweet i know how to program a little bit. and this information will come in handy in the future.

  • By Damin martin - Reply

    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.

  • By Gagan Singh - Reply

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

  • By Igor - Reply

    Hi, Gagan Singh
    Are your application store all data in /data/data/ dir?

    I think it may happens if some of your app data stores in SD card.

  • By zeus - Reply

    Thanks , I’ve been looking for this exactly .

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

    Thanks again 😀

  • By Hoffi - Reply

    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 😉

  • By Jorge Pizarro - Reply

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

  • By sreelal - Reply


    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…

    • By Igor Khrupin - Reply

      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.

  • By antony - Reply

    very nice forum

  • By chillsakoon - Reply

    Dear is there need any special permission in manifist file? for clear data, cache

  • By Aleration - Reply

    Very Good! I need this source… Thank you very very much!

  • By Thit Oo - Reply

    it was many useful for me .
    Thank a lot

  • By Gonzalo - Reply

    What should you put in the asterisks? (**********)

    • By Igor Khrupin - Reply

      Nothing. I’ve updated post for better understanding

      • By Gonzalo - Reply

        Yes!. thank you very much

  • By Peter - Reply

    Thank you so much for this nice post. A question: Why must the class extend Application? An Explanation would be great!

Leave a Reply

Your email address will not be published. Required fields are marked *
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">