AppPrefsProvider extends FDroidProvider { @Override public int update(@NonNull Uri uri, ContentValues values, String where, String[] whereArgs) { if (MATCHER.match(uri) != CODE_SINGLE) { throw new UnsupportedOperationException("Update not supported for " + uri + "."); } QuerySelection query = new QuerySelection(where, whereArgs).add(querySingle(uri.getLastPathSegment())); int count = db().update(getTableName(), values, query.getSelection(), query.getArgs()); getContext().getContentResolver().notifyChange(AppProvider.getCanUpdateUri(), null); return count; }  static Uri getAppUri(String packageName); static String getAuthority(); @Override Cursor query(@NonNull Uri uri, String[] projection,
                        String customSelection, String[] selectionArgs, String sortOrder); @Override int delete(@NonNull Uri uri, String where, String[] whereArgs); @Override Uri insert(@NonNull Uri uri, ContentValues values); @Override int update(@NonNull Uri uri, ContentValues values, String where, String[] whereArgs);  }
@Test public void newPreferences() { App withPrefs = Assert.insertApp(context, "com.example.withPrefs", "With Prefs"); App withoutPrefs = Assert.insertApp(context, "com.example.withoutPrefs", "Without Prefs"); assertNull(AppPrefsProvider.Helper.getPrefsOrNull(context, withPrefs)); assertNull(AppPrefsProvider.Helper.getPrefsOrNull(context, withoutPrefs)); AppPrefs defaultPrefs = AppPrefsProvider.Helper.getPrefsOrDefault(context, withPrefs); assertEquals(0, defaultPrefs.ignoreThisUpdate); assertFalse(defaultPrefs.ignoreAllUpdates); assertFalse(defaultPrefs.ignoreVulnerabilities); AppPrefsProvider.Helper.update(context, withPrefs, new AppPrefs(12, false, false)); AppPrefs newPrefs = AppPrefsProvider.Helper.getPrefsOrDefault(context, withPrefs); assertEquals(12, newPrefs.ignoreThisUpdate); assertFalse(newPrefs.ignoreAllUpdates); assertFalse(newPrefs.ignoreVulnerabilities); AppPrefsProvider.Helper.update(context, withPrefs, new AppPrefs(14, true, true)); AppPrefs evenNewerPrefs = AppPrefsProvider.Helper.getPrefsOrDefault(context, withPrefs); assertEquals(14, evenNewerPrefs.ignoreThisUpdate); assertTrue(evenNewerPrefs.ignoreAllUpdates); assertTrue(evenNewerPrefs.ignoreVulnerabilities); assertNull(AppPrefsProvider.Helper.getPrefsOrNull(context, withoutPrefs)); }