4

When we run an app during development on a device is sharedPreference cleared when app is reinstalled ?

Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
Avijeet
  • 1,031
  • 1
  • 10
  • 27
  • possible duplicate of [Does reinstallation of app delete SQLiteDatabase or SharedPreferences](http://stackoverflow.com/questions/21628454/does-reinstallation-of-app-delete-sqlitedatabase-or-sharedpreferences) – Anirudh Sharma Feb 25 '15 at 10:11
  • `Is sharedPreference cleared when app is reinstalled ? :` Yes – ρяσѕρєя K Feb 25 '15 at 10:12

3 Answers3

7
  • If the app is manually uninstalled first and then reinstalled, then yes, SharedPreferences and SQLite tables of the old installation are deleted.
  • If the app is updated from the Play Store or re-run from the IDE without uninstalling the previous version of app first, then SharedPreferences and SQLite tables of the old installation are still present.
Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
  • and what will happen if I get the msg "the app is already installed, Do you want to uninstall the previously installed app and install it again" (something similar I get when I try to run my app which has an old build already running on my device through eclipse run) ? – Avijeet Feb 25 '15 at 10:34
  • then the previous version of the app will be uninstalled first, the SQLite and SharedPreferences will be deleted and the new version will then be installed. – Yash Sampat Feb 25 '15 at 10:40
  • Hmm, I am a little doubtful on this case. I think even in this case the sharedPreference will remain. I will check it once in code just to be sure. Thanks for the answer – Avijeet Feb 25 '15 at 10:43
  • The best way is always to uninstall the app manually to be sure that previous data is deleted :) – Yash Sampat Feb 25 '15 at 10:44
  • I have already upvoted the answer, just waiting to get in front of my mac to test the second case :) – Avijeet Feb 25 '15 at 10:59
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/71665/discussion-between-avijeet-and-zygoteinit). – Avijeet Feb 25 '15 at 11:12
0

If you will clear the data of an application then the shared preference will be cleared hence if you reinstall an application for the first time there will be no application data so no shared preference will be there.

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98
Akash
  • 681
  • 3
  • 17
0

while reinstalling the app,shared preference never clear. While un installed and installing the app. Shared preference get cleared.