Can I store data on an Android device to persist between installs?

I want to store a small amount of data in a way where it persists between application installs. I obviously can’t use SharedPreferences as they are removes upon uninstallation. Is there any way to store data so it survives a reinstall of the app?

The data I want to store is a unique ID, to allow blocking of users of the app if they misbehave. If I cannot store an ID, can I access the Google account(s) email addresses to use them as an indicator?

  • What to do when - java.io.FileNotFoundException: No content provider?
  • How to check whether NFC is enabled or not in android?
  • Understanding a support multiply screens
  • Seemingly useless debugging environment for Android
  • Displaying emoticons in Android
  • How to set click listener for notification?
  • This blog post makes it clear none of the IDs the OS produces are any good, especially when considering tablets
    Android: Identifying app installations

    Related posts:

    Google Play Developer Console: App stuck in “Processing Update”
    Dismiss Snackbar On left swipe
    How to get TextView values from a listView Items?
    AudioTrack samplerate inconsistencies
    Android 1.6 equivalent of EXTRA_GATEWAY_URI
    Not working Notifydatasetchange on RecyclerView with center selection Horizontal Scrollview?
  • Android get list of active alarms
  • Create an IntentFilter in android that matches ALL intents
  • Determine Android phone's proximity to known point while conserving power
  • Android studio build slowed down after adding new libraries?
  • Picasso fails to load large images (from Camera and local Uri)
  • How long should registering as a Google Play developer take?
  • 3 Solutions collect form web for “Can I store data on an Android device to persist between installs?”

    You can store the data in shared preferences and use a backup manager to have them backed up automatically. They should be restored once the app is reinstalled.

    There is no real way of blocking the app for certain persons. You could fore all your users to create an account to use the app and block the accounts but they always can recreate an account. You could store something on the SD-Card and check for it but malicious users can find that and delete it. You could try to get the user to authenticate themselves with their google account against your app (andlytics is using an authentication method like that) but the user can factory reset his phone and create a new google account.

    You have to choose how important the blocking of the users is and how much you want to annoy your other users because of some users that are not using your app as intended.

    yes. you can store some data in the internal memory or the sd card.this can be done by creating(.somename)folder which is invisible to user and create a file.txt to store the data.

    If the app is removed, the data is removed. You could put something on the SD card, but there’s no reason to believe it would stay there. You might be able to work something through the application licensing mechanism. Details here

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.