I have been building an app, using SQLite to store my data. In the process, I have changed the name of the database several times. I test the app by uploading it to my tablet (Nexus 7). Are the old databases still lurking around on my tablet and, if so, how would I go about deleting them?
Asked
Active
Viewed 118 times
0
-
Starting with a search: http://stackoverflow.com/questions/4406067/how-to-delete-sqlite-database-from-android-programmatically – user2864740 Sep 03 '14 at 19:52
-
2just "Clear-data" from app info – Mohammad Ersan Sep 03 '14 at 19:52
1 Answers
2
Are the old databases still lurking around on my tablet (?)
Yes. Any old databases will still be there if you have not explicitly deleted them
how would I go about deleting them?
One of the following:
- Uninstall and re-install the app
- Go to Settings > Applications Manager > YourAppName > Clear Data
- Call
Context.deleteDatabase(DATABASE_NAME)
Realistically in the testing/debugging environment, there's no reason to delete your old databases. As long as your SQLiteOpenHelper
is using the new database name, the old database will have no impact other than consuming storage space on your device
You can also do:
String[] list = context.databaseList();
for(String name : list){
if (!name.equals(MyDatabaseOpenHelper.DATABASE_NAME))
context.deleteDatabase(name);
}

Reed
- 14,703
- 8
- 66
- 110
-
I regularly uninstall the app, but not every time I change the db name. I don't remember all the names I use. Is there an easy way of seeing what databases are still there? – Black Spike Sep 03 '14 at 20:05
-
Yeah. Open a terminal window/command prompt and type `adb shell ls /data/data/com.mydomain.myapp/databases/` – Reed Sep 03 '14 at 23:11
-
@BlackSpike, you can also use [`Context.databaseList()`](http://developer.android.com/reference/android/content/Context.html#databaseList()) – Reed Sep 17 '14 at 17:08