當前位置: 首頁>>代碼示例>>Java>>正文


Java ContentValues.putAll方法代碼示例

本文整理匯總了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;
    }
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:27,代碼來源:Assert.java

示例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);
    }
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:22,代碼來源:Assert.java

示例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);
    }
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:26,代碼來源:AppProviderTest.java

示例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;
        }
    }
 
開發者ID:piskula,項目名稱:FuelUp,代碼行數:62,代碼來源:VehicleProvider.java


注:本文中的android.content.ContentValues.putAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。