本文整理汇总了Java中android.content.ContentValues.putAll方法的典型用法代码示例。如果您正苦于以下问题:Java ContentValues.putAll方法的具体用法?Java ContentValues.putAll怎么用?Java ContentValues.putAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.ContentValues
的用法示例。
在下文中一共展示了ContentValues.putAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertApp
import android.content.ContentValues; //导入方法依赖的package包/类
public static App insertApp(Context context, String packageName, String name, ContentValues additionalValues) {
ContentValues values = new ContentValues();
values.put(AppMetadataTable.Cols.REPO_ID, 1);
values.put(AppMetadataTable.Cols.Package.PACKAGE_NAME, packageName);
values.put(AppMetadataTable.Cols.NAME, name);
// Required fields (NOT NULL in the database).
values.put(AppMetadataTable.Cols.SUMMARY, "test summary");
values.put(AppMetadataTable.Cols.DESCRIPTION, "test description");
values.put(AppMetadataTable.Cols.LICENSE, "GPL?");
values.put(AppMetadataTable.Cols.IS_COMPATIBLE, 1);
values.putAll(additionalValues);
// Don't hard code to 1, let consumers override it in additionalValues then ask for it back.
int repoId = values.getAsInteger(AppMetadataTable.Cols.REPO_ID);
Uri uri = AppProvider.getContentUri();
context.getContentResolver().insert(uri, values);
App app = AppProvider.Helper.findSpecificApp(context.getContentResolver(), packageName,
repoId, AppMetadataTable.Cols.ALL);
assertNotNull(app);
return app;
}
示例2: insertApk
import android.content.ContentValues; //导入方法依赖的package包/类
public static Uri insertApk(Context context, App app, int versionCode, ContentValues additionalValues) {
ContentValues values = new ContentValues();
values.put(ApkTable.Cols.APP_ID, app.getId());
values.put(ApkTable.Cols.VERSION_CODE, versionCode);
// Required fields (NOT NULL in the database).
values.put(ApkTable.Cols.REPO_ID, 1);
values.put(ApkTable.Cols.VERSION_NAME, "The good one");
values.put(ApkTable.Cols.HASH, "11111111aaaaaaaa");
values.put(ApkTable.Cols.NAME, "Test Apk");
values.put(ApkTable.Cols.SIZE, 10000);
values.put(ApkTable.Cols.IS_COMPATIBLE, 1);
values.putAll(additionalValues);
Uri uri = ApkProvider.getContentUri();
return context.getContentResolver().insert(uri, values);
}
示例3: insertApp
import android.content.ContentValues; //导入方法依赖的package包/类
public static App insertApp(ShadowContentResolver contentResolver, Context context, String id, String name, ContentValues additionalValues, long repoId) {
ContentValues values = new ContentValues();
values.put(Cols.Package.PACKAGE_NAME, id);
values.put(Cols.REPO_ID, repoId);
values.put(Cols.NAME, name);
// Required fields (NOT NULL in the database).
values.put(Cols.SUMMARY, "test summary");
values.put(Cols.DESCRIPTION, "test description");
values.put(Cols.LICENSE, "GPL?");
values.put(Cols.IS_COMPATIBLE, 1);
values.put(Cols.PREFERRED_SIGNER, "eaa1d713b9c2a0475234a86d6539f910");
values.putAll(additionalValues);
Uri uri = AppProvider.getContentUri();
contentResolver.insert(uri, values);
AppProvider.Helper.recalculatePreferredMetadata(context);
return AppProvider.Helper.findSpecificApp(context.getContentResolver(), id, repoId, Cols.ALL);
}
示例4: validateFillUpAndUpdate
import android.content.ContentValues; //导入方法依赖的package包/类
private int validateFillUpAndUpdate(final Uri uri, final ContentValues contentValues, long id) {
if (contentValues.size() == 0) {
return UPDATE_NO_CHANGE;
}
validateFillUpBasics(contentValues, true, id);
if (contentValues.containsKey(FillUpEntry.COLUMN_VEHICLE)) {
throw new IllegalArgumentException("Cannot change vehicle of FillUp. Please, create a fresh new FillUp in this case.");
}
boolean isDeleteAndInsertNeeded = contentValues.containsKey(FillUpEntry.COLUMN_DATE)
|| contentValues.containsKey(FillUpEntry.COLUMN_FUEL_VOLUME)
|| contentValues.containsKey(FillUpEntry.COLUMN_DISTANCE_FROM_LAST)
|| contentValues.containsKey(FillUpEntry.COLUMN_IS_FULL_FILLUP);
if (!isDeleteAndInsertNeeded) {
// if only Not-Neighbour-Affecting values have been changed
final String selection = FillUpEntry._ID + "=?";
final String[] idArgument = new String[] { String.valueOf(id) };
getContext().getContentResolver().notifyChange(uri, null);
return mDbHelper.getWritableDatabase().update(
FillUpEntry.TABLE_NAME, contentValues, selection, idArgument);
} else {
// if date, distance or fuelVolume have been changed, it may affect neighbouring fillUps
SQLiteDatabase db = mDbHelper.getWritableDatabase();
db.beginTransactionNonExclusive();
FillUp fillUp = FillUpService.getFillUpById(id, getContext());
ContentValues recreatedValues = new ContentValues();
recreatedValues.putAll(contentValues);
if (!recreatedValues.containsKey(FillUpEntry.COLUMN_VEHICLE))
recreatedValues.put(FillUpEntry.COLUMN_VEHICLE, fillUp.getVehicle().getId());
if (!recreatedValues.containsKey(FillUpEntry.COLUMN_DISTANCE_FROM_LAST))
recreatedValues.put(FillUpEntry.COLUMN_DISTANCE_FROM_LAST, fillUp.getDistanceFromLastFillUp());
if (!recreatedValues.containsKey(FillUpEntry.COLUMN_FUEL_VOLUME))
recreatedValues.put(FillUpEntry.COLUMN_FUEL_VOLUME, fillUp.getFuelVolume().doubleValue());
if (!recreatedValues.containsKey(FillUpEntry.COLUMN_FUEL_PRICE_PER_LITRE))
recreatedValues.put(FillUpEntry.COLUMN_FUEL_PRICE_PER_LITRE, fillUp.getFuelPricePerLitre().doubleValue());
if (!recreatedValues.containsKey(FillUpEntry.COLUMN_FUEL_PRICE_TOTAL))
recreatedValues.put(FillUpEntry.COLUMN_FUEL_PRICE_TOTAL, fillUp.getFuelPriceTotal().doubleValue());
if (!recreatedValues.containsKey(FillUpEntry.COLUMN_IS_FULL_FILLUP))
recreatedValues.put(FillUpEntry.COLUMN_IS_FULL_FILLUP, fillUp.isFullFillUp() ? 1 : 0);
if (!recreatedValues.containsKey(FillUpEntry.COLUMN_DATE))
recreatedValues.put(FillUpEntry.COLUMN_DATE, fillUp.getDate().getTime());
if (!recreatedValues.containsKey(FillUpEntry.COLUMN_INFO))
recreatedValues.put(FillUpEntry.COLUMN_INFO, fillUp.getInfo());
deleteFillUpInTransaction(uri, db);
validateFillUpAndInsertInTransaction(uri, recreatedValues, db);
db.setTransactionSuccessful();
db.endTransaction();
db.close();
return 1;
}
}