Nullpointerexception 使用for循环中的ContentValues插入SQLite
我尝试在SQLite中添加多条记录,类似地使用for循环,但在从函数调用和获取空指针异常时,不会获取数据:Nullpointerexception 使用for循环中的ContentValues插入SQLite,nullpointerexception,android-sqlite,content-values,Nullpointerexception,Android Sqlite,Content Values,我尝试在SQLite中添加多条记录,类似地使用for循环,但在从函数调用和获取空指针异常时,不会获取数据: ContentValues[] ans7 = new ContentValues[4]; for(int j =0; j<4; j++){ ans7[j] = new ContentValues(); ans7[j].put(KEY_ANSWER, Utils.DB_NULL_INT_VALUE); ans7[j].put(KE
ContentValues[] ans7 = new ContentValues[4];
for(int j =0; j<4; j++){
ans7[j] = new ContentValues();
ans7[j].put(KEY_ANSWER, Utils.DB_NULL_INT_VALUE);
ans7[j].put(KEY_TYPE, Utils.TYPE_NORMAL);
ans7[j].put(KEY_RESOURCE, ans7Array[j]);
if(j==1) {
ans7[j].put(KEY_IS_CORRECT, Utils.CORRECT);
}else{
ans7[j].put(KEY_IS_CORRECT, Utils.INCORRECT);
}
ans7[j].put(KEY_QUESTION_ID, 7);
long i = db.insert(TABLE_ANSWER, null, ans7[j]);
Log.e("Answer type 3", "que 7 " + i);
}
ContentValues[]ans7=新ContentValues[4];
对于(intj=0;jif-else内部正在工作。
我的错误。空指针异常是另一个原因