我的代码中的insert语句似乎有些问题 它导致我的应用程序关闭 谁能告诉我为什么?
public void insert(String clas,String sub,String name)
{
Log.i("inserted","one Record");
ContentValues values = new ContentValues();
values.put(AttendAppDbOpenHelper.COLUMN_NAME,name);
values.put(AttendAppDbOpenHelper.COLUMN_SUBJECT,sub);
values.put(AttendAppDbOpenHelper.COLUMN_CLASS, clas );
// Inserting Row
database.insert(AttendAppDbOpenHelper.TABLE_DETAILS, null, values);
DBHELPER.close(); // Closing database connection
}
答案 0 :(得分:1)
public void insertFriendList(String clas,String sub,String name) {
SQLiteDatabase slb = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(AttendAppDbOpenHelper.COLUMN_NAME,name);
values.put(AttendAppDbOpenHelper.COLUMN_SUBJECT,sub);
values.put(AttendAppDbOpenHelper.COLUMN_CLASS, clas );
slb.insert(AttendAppDbOpenHelper.TABLE_DETAILS, null, values);
slb.close();
}
试试这个 希望这可以帮到你