1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 10:19:33 +02:00

possible fix of sqlite constraint exception

This commit is contained in:
Nikolay Pultsin 2012-10-10 03:38:56 +04:00
parent 27ec0da8e3
commit fe97b64abc

View file

@ -294,7 +294,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
protected void updateBookInfo(long bookId, long fileId, String encoding, String language, String title) { protected void updateBookInfo(long bookId, long fileId, String encoding, String language, String title) {
if (myUpdateBookInfoStatement == null) { if (myUpdateBookInfoStatement == null) {
myUpdateBookInfoStatement = myDatabase.compileStatement( myUpdateBookInfoStatement = myDatabase.compileStatement(
"UPDATE Books SET file_id = ?, encoding = ?, language = ?, title = ? WHERE book_id = ?" "UPDATE OR IGNORE Books SET file_id = ?, encoding = ?, language = ?, title = ? WHERE book_id = ?"
); );
} }
myUpdateBookInfoStatement.bindLong(1, fileId); myUpdateBookInfoStatement.bindLong(1, fileId);
@ -1117,7 +1117,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
"SELECT book_id,file_name FROM Books", null "SELECT book_id,file_name FROM Books", null
); );
final SQLiteStatement deleteStatement = myDatabase.compileStatement("DELETE FROM Books WHERE book_id = ?"); final SQLiteStatement deleteStatement = myDatabase.compileStatement("DELETE FROM Books WHERE book_id = ?");
final SQLiteStatement updateStatement = myDatabase.compileStatement("UPDATE Books SET file_id = ? WHERE book_id = ?"); final SQLiteStatement updateStatement = myDatabase.compileStatement("UPDATE OR IGNORE Books SET file_id = ? WHERE book_id = ?");
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
final long bookId = cursor.getLong(0); final long bookId = cursor.getLong(0);
final long fileId = infoSet.getId(ZLFile.createFileByPath(cursor.getString(1))); final long fileId = infoSet.getId(ZLFile.createFileByPath(cursor.getString(1)));