Android Question Auto restore user data after app move?

JohnC

Expert
Licensed User
Longtime User
My phone (5.0.1 Samsung S4) has an setting in "Backup and Reset" of "Backup application data, wifi passwords, and other settings to google servers".

But it doesn't seem to restore my app's SQLite database if the user "moves" to a new device. My app will be automatically installed on the new device, but it will not have the data from the previous device.

My only thought is that I am putting the database in the "File.DirInternal", which physically places it in the /data/data/com.mycompany.myapp/files. But I also see a "/database" directory at the same level in the directory tree.

So, would putting the database in that directory properly allow google's server to restore the database on the new device when it auto-installs the app on the new device?

And if so, how would I place the database in that directory when it's adjacent to File.DirInternal directory?
 

KMatle

Expert
Licensed User
Longtime User
DirInternal is read only and no matter where you put or create the db the contents are lost. Only way: You need a server where a user can backup the data or if he moves from dev a to b add a BT or WiFi connection between the devices to copy the db (or contents). Another way is to store the data to the users account (like WhatsApp). There are examples here (see Google Drive, etc.). In the first start check if there are backups and offer to back up the data.
 
Upvote 0
Top