I create this table:
"create table " + DATABASE_TABLE + " ("
+ KEY_ROWID + " integer primary key autoincrement not null, "
+ KEY_TITLE + " text not null, "
+ KEY_BODY + " text not null, " + KEY_DATE_TIME + " text not null);"
and here is what I do for inserting:
ContentValues initialValues = new ContentValues();
initialValues.put("title", title);
initialValues.put("body", body);
initialValues.put("abc", anc);
return mDb.insert(DATABASE_TABLE, null, initialValues);
but due to some error my app force closes. Help me out please…
Logcat errors:
java.lang.NullPointerException
com.maddy.task_reminder.ReminderDbAdapter.createReminder(ReminderDbAdapter.java:133)
06-09 23:28:44.112: E/AndroidRuntime(412): at com.maddy.task_reminder.edit_activity$4.onClick(edit_activity.java:143)
If you are following the generic DBAdapter examples on the web, check that you call:
in your Activity. Otherwise
mDbis never instantiated in your database helper class, it is alwaysnull.Addition from Comment:
So this is your
open()method.If your ReminderDbAdapter constructor doesn’t look like this:
Then you need to explicitly call
ReminderDbAdapter.open()in your activity, possibly like this: