Persist app data and reuse even if app is uninstalled and installed again (using Android 11, API 30)

  • Thread starter Thread starter Android Central Question
  • Start date Start date
A

Android Central Question

It looks like Android 11 is designed such that either an app deletes its data when it gets uninstalled or the app stores the data in a remote server.

But my app requirements are different:

My app doesn't store any data on a remote server but it stores user data on user's device itself.

So, my app creates some files in Public Documents directory.

When the app is uninstalled, the data on the device doesn't get deleted.

When the user installs the app again, the app sees that there is previous data in the device and hence it tries to reuse that earlier data.

But, when trying to read the file, Android gives an error/exception that file cannot be read.

I tried setting the file permissions (when it is created for the first time) to anyone can read/write/execute but I don't think that this is working.

So, it looks like the problem is: When the app is installed again, it is a new user in the system and since it is not the owner of the files created by previous installation of the app, Android gives an error/exception.

So, is there any solution?

Or, is it that Android 11 is designed such that either an app deletes its data when it gets uninstalled or the app stores the data in a remote server?
 
Seems odd. Apps are not users.
What is the exact error code you are getting. What are the exact permissions on the existing files.

(This thread may need to be eventually moved to one of the developer forums.)
 
Yeah there is not really anything direct about this for the end user.Like Wickr for example knows if your using a new device or not. You summed up for us what the answers are I reckon.
 

Forum statistics

Threads
955,053
Messages
6,963,613
Members
3,163,185
Latest member
lzfoster