Cant Create Database In Android
below code is my databasehandler class i got it from a tutorial. Beside that tutorial i saw this method in so many forums. However, even if i have create table it doesnt seems to b
Solution 1:
The onCreate(...)
method of SQLiteHelper
isn't called until you get a reference to the database.
In your Activity
create an instance of your helper and then get a writable database from it as follows...
DatabaseHandlermyHelper=newDatabaseHandler(this);
SQLiteDatabasedb= myHelper.getWritableDatabase();
By the way, I would recommend using the name "_id" for your database ID columns if you intend to use cursors. In Android, a Cursor
must have a column specifically called _id
to work correctly. USing that specific name when creating your tables will mean you wont have to 'alias' the column name in SQL queries.
Solution 2:
The onCreate() method is only called when the database is first created on the device. Try clearing local data on the device from Settings -> Applications -> Manage applications
You could also change the database version.
Post a Comment for "Cant Create Database In Android"