Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

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?

This blog post makes it clear none of the IDs the OS produces are any good, especially when considering tablets Android: Identifying app installations

like image 1000
Ollie C Avatar asked Aug 18 '11 12:08

Ollie C


People also ask

How can I persist information in an Android device?

Android supports the following ways of storing data in the local file system: Files - You can create and update files. Preferences - Android allows you to save and retrieve persistent key-value pairs of primitive data type. SQLite database - instances of SQLite databases are also stored on the local file system.

What is data persistence in mobile application?

The capability to have data that the app uses or relies on to continue to be available regardless of changes to the app's state as it moves through the app life cycle is vital to the user experience with the app—and for the app itself to be a useful tool.

What is the meaning of data persistence?

Persistence is "the continuance of an effect after its cause is removed". In the context of storing data in a computer system, this means that the data survives after the process with which it was created has ended.

What is persistent state in Android?

Persistent data Let's say the user has typed a couple words and then exits the app. The user didn't explicitly tell us to save that data to a file, but it sure would be nice to store that data away for when they come back. This is persistent data and you want to store it away in onPause().


2 Answers

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.

like image 51
Janusz Avatar answered Sep 30 '22 18:09

Janusz


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.

like image 24
bladeX Avatar answered Sep 30 '22 16:09

bladeX