Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find and clear the SQLite db file in Android (emulator)

Tags:

android

sqlite

I've just got my first SQLite database up and running but to reproduce it I wanted a quick way to clear the db file (so I can call my openOrCreateDatabase method again)

First question: I see all over the web /data/data/PKG/databases/ but where exactly is this stored on a windows machine? It doesn't appear to be in my local project folder because when I do a simple git status, no *.db file is listed after the create is successful.

Also if I wanted to clear this is it a simple delete and the emulator will know to re create this? If not how can I clear it from the emulator? (thinking iPhone here where you had to delete and re-push the app to the simulator to clear this out and have the db re-created)

like image 375
Toran Billups Avatar asked Jun 14 '11 04:06

Toran Billups


People also ask

Where is SQLite database stored in Android emulator?

The databases are stored as SQLite files in /data/data/PACKAGE/databases/DATABASEFILE where: PACKAGE is the package declared in the AndroidManifest.


1 Answers

It's stored inside the emulator, not on your machine (at least, not in a place that is easily accessible). Just remove it using adb:

C:\> adb -e shell rm /data/data/com.example.package/databases/*.db

You can also choose the "Wipe user data" option when launching the emulator AVD, or you can uninstall the application to wipe all data for just that one app:

C:\> adb -e uninstall com.example.package

Finally, you can also just clear user data for a given application without uninstalling it, by going to Settings > Applications > Manage Applications... Select your application, then click the "Clear Data" button.

like image 198
Joe Avatar answered Oct 15 '22 10:10

Joe