Example usage for android.content ContentValues put

List of usage examples for android.content ContentValues put

Introduction

In this page you can find the example usage for android.content ContentValues put.

Prototype

public void put(String key, byte[] value) 

Source Link

Document

Adds a value to the set.

Usage

From source file:com.kku.apps.pricesearch.util.Utils.java

public static void entryFavorites(Context context, ListItem item) {
    final ContentValues cv = new ContentValues();
    cv.put(FavoritesColumns.KEYWORDS, item.getKeywords());
    cv.put(FavoritesColumns.NAME, item.getName());
    if (item.getImage() != null) {
        cv.put(FavoritesColumns.IMAGE, getByteImage(item.getImage()));
    }//  ww w.  j  a  va2s .c  o m
    cv.put(FavoritesColumns.ITEMURL, item.getItemUrl());
    cv.put(FavoritesColumns.PRICE, item.getPrice());
    cv.put(FavoritesColumns.SHOP, item.getShop());
    cv.put(FavoritesColumns.LOGO, item.getLogo());
    cv.put(FavoritesColumns.DATE, Utils.getDate());
    final AsyncQueryHandler dbHandler = new AsyncQueryHandler(context.getContentResolver()) {

        @Override
        protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
            super.onQueryComplete(token, cookie, cursor);
        }
    };
    dbHandler.startInsert(0, null, SearchContract.URI_FAVORITES, cv);
}

From source file:info.guardianproject.otr.app.im.app.DatabaseUtils.java

/** Update the data of a plugin provider. */
private static int updateProviderRow(ContentResolver cr, long providerId, String providerFullName,
        String signUpUrl) {//from w w w . ja  v  a  2s. c o  m
    // Update the full name, signup url and category each time when the plugin change
    // instead of specific version change because this is called only once.
    // It's ok to update them even the values are not changed.
    // Note that we don't update the provider name because it's used as
    // identifier at some place and the plugin should never change it.
    ContentValues values = new ContentValues(3);
    values.put(Imps.Provider.FULLNAME, providerFullName);
    values.put(Imps.Provider.SIGNUP_URL, signUpUrl);
    values.put(Imps.Provider.CATEGORY, ImApp.IMPS_CATEGORY);
    Uri uri = ContentUris.withAppendedId(Imps.Provider.CONTENT_URI, providerId);
    return cr.update(uri, values, null, null);
}

From source file:info.guardianproject.otr.app.im.app.DatabaseUtils.java

/** Insert the plugin settings into the database. */
private static int saveProviderSettings(ContentResolver cr, long providerId, Map<String, String> config) {
    ContentValues[] settingValues = new ContentValues[config.size()];
    int index = 0;
    for (Map.Entry<String, String> entry : config.entrySet()) {
        ContentValues settingValue = new ContentValues();
        settingValue.put(Imps.ProviderSettings.PROVIDER, providerId);
        settingValue.put(Imps.ProviderSettings.NAME, entry.getKey());
        settingValue.put(Imps.ProviderSettings.VALUE, entry.getValue());
        settingValues[index++] = settingValue;
    }//from  ww w  .j  ava  2s  . co m
    return cr.bulkInsert(Imps.ProviderSettings.CONTENT_URI, settingValues);
}

From source file:Main.java

public static ArrayList<ContentValues> getProvince(SQLiteDatabase db) {
    ArrayList<ContentValues> list = new ArrayList<ContentValues>();
    ContentValues values = null;
    Cursor cursor = db.query(TABLE_NAME, new String[] { "DQXX01", "DQXX02" }, "DQXX03=?", new String[] { "1" },
            null, null, "DQX_DQXX01 ASC");
    if (cursor != null) {
        while (cursor.moveToNext()) {
            values = new ContentValues();
            values.put("province_id", cursor.getInt(0));
            values.put("province", cursor.getString(1));
            list.add(values);/*from   w w w.j  a  v  a  2s. c  o  m*/
        }
    }
    if (cursor != null && !cursor.isClosed()) {
        cursor.close();
    }
    return list;
}

From source file:com.goliathonline.android.kegbot.io.RemoteKegHandler.java

private static ContentValues queryKegDetails(Uri uri, ContentResolver resolver) {
    final ContentValues values = new ContentValues();
    final Cursor cursor = resolver.query(uri, KegsQuery.PROJECTION, null, null, null);
    try {/*  w  ww .ja v  a2s  .  c  o  m*/
        if (cursor.moveToFirst()) {
            values.put(SyncColumns.UPDATED, cursor.getLong(KegsQuery.UPDATED));
            values.put(Kegs.KEG_STARRED, cursor.getInt(KegsQuery.STARRED));
        } else {
            values.put(SyncColumns.UPDATED, KegbotContract.UPDATED_NEVER);
        }
    } finally {
        cursor.close();
    }
    return values;
}

From source file:com.goliathonline.android.kegbot.io.RemoteTapHandler.java

private static ContentValues queryTapDetails(Uri uri, ContentResolver resolver) {
    final ContentValues values = new ContentValues();
    final Cursor cursor = resolver.query(uri, TapsQuery.PROJECTION, null, null, null);
    try {/*from w w w  . j a va 2  s.co  m*/
        if (cursor.moveToFirst()) {
            values.put(SyncColumns.UPDATED, cursor.getLong(TapsQuery.UPDATED));
        } else {
            values.put(SyncColumns.UPDATED, KegbotContract.UPDATED_NEVER);
        }
    } finally {
        cursor.close();
    }
    return values;
}

From source file:com.goliathonline.android.kegbot.io.RemoteDrinksHandler.java

private static ContentValues queryDrinkDetails(Uri uri, ContentResolver resolver) {
    final ContentValues values = new ContentValues();
    final Cursor cursor = resolver.query(uri, SessionsQuery.PROJECTION, null, null, null);
    try {//  w  w  w.  j  a v a2 s . c  o m
        if (cursor.moveToFirst()) {
            values.put(SyncColumns.UPDATED, cursor.getLong(SessionsQuery.UPDATED));
            values.put(Drinks.DRINK_STARRED, cursor.getInt(SessionsQuery.STARRED));
        } else {
            values.put(SyncColumns.UPDATED, KegbotContract.UPDATED_NEVER);
        }
    } finally {
        cursor.close();
    }
    return values;
}

From source file:net.ccghe.emocha.model.DBAdapter.java

public static boolean markForDeletion(String path, boolean state) {
    ContentValues values = new ContentValues();
    values.put("to_delete", state ? 1 : 0);
    return sDB.update(TABLE_DOWNLOADS, values, "path='" + path + "'", null) > 0;
}

From source file:net.ccghe.emocha.model.DBAdapter.java

public static boolean markForDeletion(boolean state) {
    ContentValues values = new ContentValues();
    values.put("to_delete", state ? 1 : 0);
    return sDB.update(TABLE_DOWNLOADS, values, null, null) > 0;
}

From source file:net.ccghe.emocha.model.DBAdapter.java

public static boolean markForDownload(String path, String newMD5) {
    ContentValues values = new ContentValues();
    values.put("to_download", 1);
    values.put("md5", newMD5);
    return sDB.update(TABLE_DOWNLOADS, values, "path='" + path + "'", null) > 0;
}