Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android SQLite database removed after uninstall

Tags:

android

sqlite

I want to know one thing related sqlite in android.

When i install my app and run it and do my operation's save some data and read data.

but when i uninstall my app and install it again.

I tried to read data but it does not show any thing .It means database deleted on uninstall the app.

If yes ,how to prevent my database to uninstall.

like image 618
Monty Avatar asked Jan 28 '13 04:01

Monty


1 Answers

I'm assuming you're creating your database on the internal storage as most apps do.

When you uninstall your app, the entire data directory of the app is deleted. This includes databases, preferences, other files, caches etc.

You could try saving the database to the SD Card instead and reading from there. However, you will now lose access to the database if the user changes the SD Card or mounts it to the computer pre honeycomb.

Another option would be to back it up to a server at regular intervals and restore the backup from there manually, or implement something like the Google BackupAgent, which will automatically backup data if the user configures his/her device to backup against the Google account to which it is registered.

If you're worried about your data being read by others, encrypt it using AES or some other encryption technique.

like image 87
Raghav Sood Avatar answered Oct 28 '22 02:10

Raghav Sood