2011-03-07 65 views
0

我是新來的,我正在爲我的第一個android應用程序開發類。每次我使用mDb.insert()時,都會返回「-1」。Android SQLite返回-1

簡單地說,我有:

private SQLiteDatabase mDb; 
ContentValues intialValues; //I then .put() some stuff into intialValues 
return mDb.insert("mytable", null, initialValues); 

我得-1。

回答

1

使用insertOrThrow可以獲得更好的調試信息。我的心理調試能力表示,您沒有正確實例化mDb使用數據庫打開幫助器上的可寫方法。