Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens to a Sqlite database when app is removed

Tags:

android

sqlite

I'm new to Android programming and trying to wrap my head around this just to make myself clear about how things work.

When creating Sqlite databases in an Android app, where is the database stored? Does it get deleted when the app is removed? Any info about this would be much helpful in understanding Android programming for people coming from a web development background.

like image 633
Zishan Neno Avatar asked Mar 07 '12 13:03

Zishan Neno


People also ask

Does uninstalling an app delete database?

Generally No actually. When you uninstall, the APK itself (/data/app/com. example. app-1.

Is SQLite database permanent?

SQLite tables are persistent in Android - they exist as files in a particular directory based on your application's package id.

How do you keep SQLite database on an Android device if the app is uninstalled?

You can't keep the database files if they are saved in this location. But If you save your database files to SD card, the files are kept even after uninstall.

Can multiple applications use the same SQLite database?

Yes, they can!


1 Answers

SQlite databases are just files, and they're treated like any other file: they're stored (by default) in the application's private data area (/data/data/$PACKAGENAME/databases). They're deleted along with everything else in the application's private data area.

You can create a database on the SD card if you like. They, of course, won't be removed on uninstallation.

like image 107
David Given Avatar answered Oct 23 '22 04:10

David Given