在 android 中使用 sqlite 数据库时,我遇到了一个奇怪的问题。我在一个表中插入了大约 500 个输入,但是当表有大约 260-270 个输入时,它显示了这个异常:
sqLiteCantOpenDatabaseException
代码:
public last_open open() throws SQLException {db = DBHelper.getWritableDatabase();return this;}
public void close() {DBHelper.close();}
public static void insert(
String STUDENT_ID,
String COURSE_ID,
String PACKAGE_ID,
String ITEM_NAME,
String ITEM_ID,
String LAST_OPEN
){
try{
ContentValues initialValues = new ContentValues();
initialValues.put(T_STUDENT_ID,STUDENT_ID);
initialValues.put(T_COURSE_ID, COURSE_ID);
initialValues.put(T_PACKAGE_ID, PACKAGE_ID);
initialValues.put(T_ITEM_NAME,ITEM_NAME);
initialValues.put(T_ITEM_ID, ITEM_ID);
initialValues.put(T_LAST_OPEN,LAST_OPEN);
// db.insert("LAST_OPEN", null, initialValues);
db.execSQL("DELETE FROM LAST_OPEN WHERE STUDENT_ID="+STUDENT_ID+" AND COURSE_ID="+COURSE_ID+" AND PACKAGE_ID="+PACKAGE_ID+" AND ITEM_ID="+ITEM_ID+" AND ITEM_NAME='"+ITEM_NAME+"';");
db.execSQL("INSERT INTO LAST_OPEN(STUDENT_ID,COURSE_ID,PACKAGE_ID,ITEM_NAME,ITEM_ID,LAST_OPEN) VALUES ("+STUDENT_ID+","+COURSE_ID+","+PACKAGE_ID+","+"'"+ITEM_NAME+"'"+","+ITEM_ID+","+"'"+LAST_OPEN+"'"+");");
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
这些是我正在使用的方法::
日志:
SqliteDatabaseCpp(586): sqlite returned: error code = 14, msg = cannot open file at line 27360 of [8609a15dfa], db=/data/data/com.cuelearn.main/databases/cuelearn
SqliteDatabaseCpp(586): sqlite returned: error code = 14, msg = os_unix.c: open() at line 27360 - "" errno=24 path=/data/data/com.cuelearn.main/databases, db=/data/data/com.cuelearn.main/databases/cuelearn
SqliteDatabaseCpp(586): sqlite returned: error code = 14, msg = statement aborts at 28: [DELETE FROM LAST_OPEN WHERE STUDENT_ID=95 AND COURSE_ID=2 AND PACKAGE_ID=13 AND ITEM_ID=267 AND ITEM_NAME='Chapter';] , db=/data/data/com.cuelearn.main/databases/cuelearn
enter code here
System.err(586): android.database.sqlite.SQLiteCantOpenDatabaseException: error code 14: unable to open database file
我不知道如何解决这个问题,我也没有得到这个原因。我看到有人在尝试从资产复制数据库时遇到此异常。但在我的情况下,我没有复制数据库。请帮助我,我使用的是 Android 4.0.3?