@Test public void testInsert() { Cursor cursor = queryAllApks(); assertNotNull(cursor); assertEquals(0, cursor.getCount()); cursor.close(); Apk apk = new MockApk("org.fdroid.fdroid", 13); Assert.insertApk(context, apk.packageName, apk.versionCode); cursor = queryAllApks(); assertNotNull(cursor); assertEquals(1, cursor.getCount()); cursor.moveToFirst(); Apk toCheck = new Apk(cursor); cursor.close(); assertEquals("org.fdroid.fdroid", toCheck.packageName); assertEquals(13, toCheck.versionCode); }
@Override public Uri insert(@NonNull Uri uri, ContentValues values) { boolean saveAntiFeatures = false; String[] antiFeatures = null; if (values.containsKey(Cols.AntiFeatures.ANTI_FEATURES)) { saveAntiFeatures = true; String antiFeaturesString = values.getAsString(Cols.AntiFeatures.ANTI_FEATURES); antiFeatures = Utils.parseCommaSeparatedString(antiFeaturesString); values.remove(Cols.AntiFeatures.ANTI_FEATURES); } removeFieldsFromOtherTables(values); validateFields(Cols.ALL, values); long newId = db().insertOrThrow(getTableName(), null, values); if (saveAntiFeatures) { ensureAntiFeatures(antiFeatures, newId); } if (!isApplyingBatch()) { getContext().getContentResolver().notifyChange(uri, null); } return getApkUri(newId); }
ApkProvider extends FDroidProvider { @Override public Uri insert(@NonNull Uri uri, ContentValues values) { boolean saveAntiFeatures = false; String[] antiFeatures = null; if (values.containsKey(Cols.AntiFeatures.ANTI_FEATURES)) { saveAntiFeatures = true; String antiFeaturesString = values.getAsString(Cols.AntiFeatures.ANTI_FEATURES); antiFeatures = Utils.parseCommaSeparatedString(antiFeaturesString); values.remove(Cols.AntiFeatures.ANTI_FEATURES); } removeFieldsFromOtherTables(values); validateFields(Cols.ALL, values); long newId = db().insertOrThrow(getTableName(), null, values); if (saveAntiFeatures) { ensureAntiFeatures(antiFeatures, newId); } if (!isApplyingBatch()) { getContext().getContentResolver().notifyChange(uri, null); } return getApkUri(newId); } }
ApkProvider extends FDroidProvider { @Override public Uri insert(@NonNull Uri uri, ContentValues values) { boolean saveAntiFeatures = false; String[] antiFeatures = null; if (values.containsKey(Cols.AntiFeatures.ANTI_FEATURES)) { saveAntiFeatures = true; String antiFeaturesString = values.getAsString(Cols.AntiFeatures.ANTI_FEATURES); antiFeatures = Utils.parseCommaSeparatedString(antiFeaturesString); values.remove(Cols.AntiFeatures.ANTI_FEATURES); } removeFieldsFromOtherTables(values); validateFields(Cols.ALL, values); long newId = db().insertOrThrow(getTableName(), null, values); if (saveAntiFeatures) { ensureAntiFeatures(antiFeatures, newId); } if (!isApplyingBatch()) { getContext().getContentResolver().notifyChange(uri, null); } return getApkUri(newId); }  }
ApkProvider extends FDroidProvider { @Override public Uri insert(@NonNull Uri uri, ContentValues values) { boolean saveAntiFeatures = false; String[] antiFeatures = null; if (values.containsKey(Cols.AntiFeatures.ANTI_FEATURES)) { saveAntiFeatures = true; String antiFeaturesString = values.getAsString(Cols.AntiFeatures.ANTI_FEATURES); antiFeatures = Utils.parseCommaSeparatedString(antiFeaturesString); values.remove(Cols.AntiFeatures.ANTI_FEATURES); } removeFieldsFromOtherTables(values); validateFields(Cols.ALL, values); long newId = db().insertOrThrow(getTableName(), null, values); if (saveAntiFeatures) { ensureAntiFeatures(antiFeatures, newId); } if (!isApplyingBatch()) { getContext().getContentResolver().notifyChange(uri, null); } return getApkUri(newId); }  static String getAuthority(); static Uri getContentUri(); static Uri getAppUri(String packageName); static Uri getRepoUri(long repoId); static Uri getRepoUri(long repoId, String packageName); static Uri getApkFromAnyRepoUri(Apk apk); static Uri getApkFromAnyRepoUri(String packageName, int versionCode, @Nullable String signature); @Override Cursor query(@NonNull Uri uri, String[] projection, String selection,
                        String[] selectionArgs, String sortOrder); @Override Uri insert(@NonNull Uri uri, ContentValues values); @Override int delete(@NonNull Uri uri, String where, String[] whereArgs); @Override int update(@NonNull Uri uri, ContentValues values, String where, String[] whereArgs); }
ApkProvider extends FDroidProvider { @Override public Uri insert(@NonNull Uri uri, ContentValues values) { boolean saveAntiFeatures = false; String[] antiFeatures = null; if (values.containsKey(Cols.AntiFeatures.ANTI_FEATURES)) { saveAntiFeatures = true; String antiFeaturesString = values.getAsString(Cols.AntiFeatures.ANTI_FEATURES); antiFeatures = Utils.parseCommaSeparatedString(antiFeaturesString); values.remove(Cols.AntiFeatures.ANTI_FEATURES); } removeFieldsFromOtherTables(values); validateFields(Cols.ALL, values); long newId = db().insertOrThrow(getTableName(), null, values); if (saveAntiFeatures) { ensureAntiFeatures(antiFeatures, newId); } if (!isApplyingBatch()) { getContext().getContentResolver().notifyChange(uri, null); } return getApkUri(newId); }  static String getAuthority(); static Uri getContentUri(); static Uri getAppUri(String packageName); static Uri getRepoUri(long repoId); static Uri getRepoUri(long repoId, String packageName); static Uri getApkFromAnyRepoUri(Apk apk); static Uri getApkFromAnyRepoUri(String packageName, int versionCode, @Nullable String signature); @Override Cursor query(@NonNull Uri uri, String[] projection, String selection,
                        String[] selectionArgs, String sortOrder); @Override Uri insert(@NonNull Uri uri, ContentValues values); @Override int delete(@NonNull Uri uri, String where, String[] whereArgs); @Override int update(@NonNull Uri uri, ContentValues values, String where, String[] whereArgs);  }