Reputation: 2072
why SqlLite query in android produce Nullpointer exception I am using this code
public void onCreate(SQLiteDatabase db)
{
String newTableQueryString = "create table " +TABLE_NAME +" (" +
TABLE_ROW_ID + " integer primary key autoincrement not null," +
TABLE_ROW_ONE + " text," +
TABLE_ROW_TWO + " text" +
");";
Log.e("check","table have been created"+newTableQueryString);
try{
mdb.execSQL(newTableQueryString);//it produce exce[ption
}catch(Exception e)
{
Log.e("Exception"," "+ e.getMessage());
e.printStackTrace();
}
}
Upvotes: 0
Views: 233
Reputation: 2079
My guess is mdb is null when you call:
mdb.execSQL(newTableQueryString);
Did you mean to invoke the execSQL method on the db method parameter that you're passing into the onCreate method?
Upvotes: 1