tags:

views:

587

answers:

3

Can anyone tell me how to update the database in android. I created an app with an embedded database. I changed the version of the database in the manifest and created the on update method. I wanted to test it to see if the database was updating properly but when I use the adb command only the -r will allow me to do a reinstall but it keeps the database. Is there a way to run the adb command that will allow me to update the database. Thanks.

+1  A: 
Israel ANY
thanks for the links but I did not see anything that talked about doing an adb reinstall and updating the database. Is it possible to do this, my app creates that database fine the first time but only during the updates is when it crashes. Is there a manifest entry I need to enter?
never mind I found out what I was doing wrong, after some research I found out that I was not dropping the table correctly and when I would recreate the table it would error out. I ended up dropping the table correctly and instead of calling the oncreate command I just wrote a query to recreate the table in the onupdate method.
A: 

What worked for me is changing the version number for the database. This is the constant number that is used by the onCreate() method of your content provider. Something similar works if you don't use a content provider for your database, and query it directly. See source code example here.

r1k0
A: 

What worked for me is changing the version number parameter that I provide to the DBOpenHelper class which extends the SQLiteOpenHelper (the class used for creating/read/writing/etc... the Android database). When the version number parameter is incremented, the onUpdate() function is called once for the new value of this parameter.

jaxvy