开发者

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

开发者 https://www.devze.com 2023-03-28 19:47 出处:网络
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 st

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 开发者_如何学PythonI 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消