While using sqlite database in android I am getting a weird problem.
I am inserting about 500 enteries in a table but when the table has around 260-270 enteries it shows this exception:
sqLiteCantOpenDatabaseException
CODE:
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();
}
}
These are the methods I am using ::
Log:
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
I dont know how to solve this problem neither I am getting the cause of this. I have seen some people getting this exception when trying to copy database from assets.But in my case I am not copying the database.Please help me I am using Android 4.0.3?
its possible that you are trying to open a database file which is already open.