Deleting SQLite database in android

If you are in the process of developing an android app that uses SQLite, you probably have found yourself in the situation where you wanted to restructure the database.  Instead of bumping the version on the helper class and putting in upgrade logic, it is best to just start over with a fresh database when you haven’t yet released your new version of the app.  Here’s how you zap your database in the emulator’s file system.

First, find out the serial number of the emulator as it is running:

$ adb devices
List of devices attached
emulator-5554    device

Now, connect a shell and delete the file from the filesystem:

$ adb emulator-5554 shell
# rm /data/data/<yourpackage>/databases/<databaseName>
# exit

After that, your database should be gone and will be recreated next time you run the helper to get a connection.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s