0

为什么android中的SqlLite查询会产生Nullpointer异常我正在使用这段代码

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();
            }
    }
4

1 回答 1

1

我的猜测是当您调用时 mdb 为空:

 mdb.execSQL(newTableQueryString);

您的意思是在传递给 onCreate 方法的 db 方法参数上调用 execSQL 方法吗?

于 2012-02-22T03:07:36.643 回答