use of androidx.sqlite.db.SupportSQLiteDatabase in project Rocket by mozilla-tw.
the class HistoryProvider method update.
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
if (sUriMatcher.match(uri) != BROWSING_HISTORY) {
throw new UnsupportedOperationException("URI: " + uri);
}
final SupportSQLiteDatabase db = mDbHelper.getWritableDatabase();
final int count = db.update(Tables.BROWSING_HISTORY, OnConflictStrategy.ROLLBACK, values, selection, selectionArgs);
if (count > 0) {
notifyBrowsingHistoryChange();
}
return count;
}
use of androidx.sqlite.db.SupportSQLiteDatabase in project Rocket by mozilla-tw.
the class HistoryProvider method query.
@Override
public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
if (sUriMatcher.match(uri) != BROWSING_HISTORY) {
throw new IllegalArgumentException("URI: " + uri);
}
final SupportSQLiteDatabase db = mDbHelper.getReadableDatabase();
SupportSQLiteQuery query = SupportSQLiteQueryBuilder.builder(Tables.BROWSING_HISTORY).columns(projection).selection(selection, selectionArgs).orderBy(sortOrder).limit(ProviderUtils.getLimitParam(uri.getQueryParameter("offset"), uri.getQueryParameter("limit"))).create();
return db.query(query);
}
use of androidx.sqlite.db.SupportSQLiteDatabase in project Rocket by mozilla-tw.
the class HistoryProvider method insert.
@Override
public Uri insert(Uri uri, ContentValues initialValues) {
final SupportSQLiteDatabase db = mDbHelper.getWritableDatabase();
long id;
switch(sUriMatcher.match(uri)) {
case BROWSING_HISTORY:
final ContentValues values = new ContentValues(initialValues);
id = insertWithUrlUnique(db, values);
break;
default:
throw new UnsupportedOperationException("URI: " + uri);
}
if (id < 0) {
return null;
} else {
notifyBrowsingHistoryChange();
return ContentUris.withAppendedId(uri, id);
}
}
use of androidx.sqlite.db.SupportSQLiteDatabase in project Rocket by mozilla-tw.
the class TabDaoTest method migrationFrom1To2_containsCorrectData.
@Test
public void migrationFrom1To2_containsCorrectData() throws IOException {
// Create the database in version 1
SupportSQLiteDatabase db = testHelper.createDatabase(TEST_DB_NAME, 1);
// Insert some data
insertTabV1(TAB, db);
insertTabV1(TAB_2, db);
db.close();
// Re-open the database with version 2 and provide MIGRATION_1_2 as the migration process.
testHelper.runMigrationsAndValidate(TEST_DB_NAME, 2, true, TabsDatabase.MIGRATION_1_2);
// MigrationTestHelper automatically verifies the schema changes, but not the data validity
// Validate that the data was migrated properly.
List<TabEntity> dbTabs = getMigratedRoomDatabase().tabDao().getTabs();
assertEquals(2, dbTabs.size());
assertTabEquals(TAB, dbTabs.get(0));
assertTabEquals(TAB_2, dbTabs.get(1));
}
Aggregations