Search code examples
androiddatabaseadb

Deleting application database from emulator


I'm testing an application I'm working on and I wanted to delete the database my application creates so I could read all the data from my web server back in to a fresh one.

I launched adb, went to data/data/my.applicaton.package/databases and did a "rm mydatabase". This deleted the database (note: I've done this many many times before without a problem).

I launched my application again and, to my surprise, a new database wasn't created. Even more surprising is there was data in my application. My application is still pulling the data from some where! It gets a Cursor from my database and uses a CursorAdapter to populate the list. So, it is obviously reading from a database (seemingly a cached one?).

Exactly where is it pulling from and why? It's pointed at a database that is now deleted.


Solution

  • Are you sure you hadn't started the app, hit home/back to get to main screen, then did your adb magic? If you did that, then the program was still running in the background and the changes to the database were not picked up correctly. You should make sure to kill the running process in DDMS of your application before making changes to the database. Then launch the application and see if the changes are picked up.

    I've run into this issue many times.