0

I would like to know if there's a way to store simple data like int, double, string that will survive to an uninstall app process. Thanks and regards.

3 Answers3

0

I think this can help you.You can easily set it form manifest file. https://developer.android.com/guide/topics/data/autobackup

Oğuz Ayan
  • 21
  • 3
  • I tried to use autobackup with no fortune system callbacks were not called by OS for some reasons that I ignore. – user1254938 Aug 05 '21 at 08:47
0

One way is directly save the data to a directory other than the cache directory of the app. For example, you can create a folder named test1 in the root directory of the SD card and save the data to the directory test1. For details about how to apply for storage permissions for SDK 30, see this Android 11 Scoped storage permissions.

When an application is uninstalled, other external storage directories are not deleted.

Matrix
  • 503
  • 3
  • 17
  • I'm not sure if I'm wrong, but to do what you're suggesting I should ask for MANAGE_EXTERNAL_STORAGE and is not in my plan. – user1254938 Aug 05 '21 at 08:50
0

To identify returning user?

I think all ways storing data locally are not guaranteed, as Google is putting more and more restriction on external storage, only a File manager app is allowed to write external storage now.

So the best way I can think of is to get the device's unique id and store it in a server. And you check your server with the IMEI to see if the user is a returning user.

IMEI can be used as unique id of the device. It is something like this:

val telephonyManager = context.getSystemService(context.TELEPHONY_SERVICE) as TelephonyManager
val imei = telephonyManager.getDeviceId()

Then record IMEI in your server. You will need READ_PHONE_STATE permission.

AIMIN PAN
  • 1,563
  • 1
  • 9
  • 13