use of com.squareup.sqlbrite.BriteDatabase in project Shuttle by timusus.
the class WhitelistHelper method addToWhitelist.
public static void addToWhitelist(List<String> paths) {
BriteDatabase db = DataManager.getInstance().getWhitelistDatabase();
BriteDatabase.Transaction transaction = db.newTransaction();
try {
Stream.of(paths).map(path -> {
ContentValues contentValues = new ContentValues();
contentValues.put(WhitelistDbOpenHelper.COLUMN_FOLDER, path);
return contentValues;
}).forEach(contentValues -> db.insert(WhitelistDbOpenHelper.TABLE_FOLDERS, contentValues));
transaction.markSuccessful();
} finally {
transaction.end();
}
}
use of com.squareup.sqlbrite.BriteDatabase in project sqlbrite by square.
the class DbModule method provideDatabase.
@Provides
@Singleton
BriteDatabase provideDatabase(SqlBrite sqlBrite, SQLiteOpenHelper helper) {
BriteDatabase db = sqlBrite.wrapDatabaseHelper(helper, Schedulers.io());
db.setLoggingEnabled(true);
return db;
}
use of com.squareup.sqlbrite.BriteDatabase in project Shuttle by timusus.
the class BlacklistHelper method addToBlacklist.
public static void addToBlacklist(List<Song> songs) {
BriteDatabase db = DataManager.getInstance().getBlacklistDatabase();
BriteDatabase.Transaction transaction = db.newTransaction();
try {
Stream.of(songs).map(song -> {
ContentValues contentValues = new ContentValues();
contentValues.put(BlacklistDbOpenHelper.COLUMN_SONG_ID, song.id);
return contentValues;
}).forEach(contentValues -> db.insert(BlacklistDbOpenHelper.TABLE_SONGS, contentValues));
transaction.markSuccessful();
} finally {
transaction.end();
}
}
Aggregations