Android / Sqlite / Multiple Tables
I am creating my first android application, and I'm having issues with creating a 2nd table in my database. This is my code: (DatabaseHelper.java) public class DataBaseHelper exten
Solution 1:
Try changing
staticfinalint DATABASE_VERSION = 1;
to
staticfinalint DATABASE_VERSION = 2;
I suspect you ran the code after you created just the first table and then added the code to create the second. Because the version number hasn't changed, it thinks it's already created version 1, so doesn't re-run the creation. Alternatively you could delete the database from the device and then keeping it at version 1 would be OK.
By incrementing the DATABASE_VERSION, you'll force the onUpgrade
method to run which in turn calls the onCreate
.
Post a Comment for "Android / Sqlite / Multiple Tables"