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

favorites code: simplified

This commit is contained in:
Nikolay Pultsin 2013-01-29 14:59:57 +00:00
parent 82cc9fd8d2
commit 8207b5db87
11 changed files with 101 additions and 46 deletions

View file

@ -691,6 +691,25 @@ final class SQLiteBooksDatabase extends BooksDatabase {
return ids;
}
protected boolean hasFavorites() {
final Cursor cursor = myDatabase.rawQuery(
"SELECT book_id FROM Favorites LIMIT 1", null
);
boolean result = cursor.moveToNext();
cursor.close();
return result;
}
protected boolean isFavorite(long bookId) {
final Cursor cursor = myDatabase.rawQuery(
"SELECT book_id FROM Favorites WHERE book_id = ? LIMIT 1",
new String[] { String.valueOf(bookId) }
);
boolean result = cursor.moveToNext();
cursor.close();
return result;
}
private SQLiteStatement myAddToFavoritesStatement;
protected void addToFavorites(long bookId) {
if (myAddToFavoritesStatement == null) {