SQLiteDatabase replace - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SQLiteDatabase replace method.

This code example shows how to use the following methods:replace
        values.put(HISTORY_ORDER_ID_COL, orderId);
        values.put(HISTORY_PRODUCT_ID_COL, productId);
        values.put(HISTORY_STATE_COL, state.ordinal());
        values.put(HISTORY_PURCHASE_TIME_COL, purchaseTime);
        values.put(HISTORY_DEVELOPER_PAYLOAD_COL, developerPayload);
        mDb.replace(PURCHASE_HISTORY_TABLE_NAME, null /* nullColumnHack */, values);
    } 
 
    /** 
     * Updates the quantity of the given product to the given value. If the 
     * given value is zero, then the product is removed from the table. 
     * @param productId the product to update 
     * @param quantity the number of times the product has been purchased 
     */ 
    private void updatePurchasedItem(String productId, int quantity) {
        if (quantity == 0) {
            mDb.delete(PURCHASED_ITEMS_TABLE_NAME, PURCHASED_PRODUCT_ID_COL + "=?",
                    new String[] { productId });
            return; 
        } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:insert, replace
	public void storeCertificate(String certificateHash, long coreId) {
		try { 
			ContentValues value = new ContentValues();
			value.put(KEY_CERTIFICATE, certificateHash);
			value.put(KEY_COREIDREFERENCE, coreId);
			long res = db.insert(CERTIFICATE_TABLE, null, value);
			if(res == -1) {
				db.replace(CERTIFICATE_TABLE, null, value);
			} 
		} catch(SQLException e) {
			e.printStackTrace();
		} 
	} 
 
	public String getCertificate(long coreId) {
		Cursor c = db.query(CERTIFICATE_TABLE, new String[] {KEY_CERTIFICATE}, KEY_COREIDREFERENCE + "=" + coreId, null, null, null, null);
		String cert = null;
		if (c != null && c.getCount() > 0) {
			c.moveToFirst();
			cert = c.getString(c.getColumnIndex(KEY_CERTIFICATE));
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:replace, update
    @Deprecated 
    public synchronized void setKeyValVal(String key, String val) {
        ContentValues values = new ContentValues();
        values.put(KEYVAL_COLUMN_VAL, val);
 
        int affected = mStoreDB.update(KEYVAL_TABLE_NAME, values, KEYVAL_COLUMN_KEY + "='" + key + "'", null);
        if (affected == 0){
            values.put(KEYVAL_COLUMN_KEY, key);
            mStoreDB.replace(KEYVAL_TABLE_NAME, null, values);
        } 
    } 
 
    /** 
     * Gets the value for the given key. 
     * @param key the key of the key-val pair. 
     * @return a value for the given key. 
     */ 
    @Deprecated 
    public synchronized Cursor getKeyValVal(String key) {
        return mStoreDB.query(KEYVAL_TABLE_NAME, KEYVAL_COLUMNS, KEYVAL_COLUMN_KEY + "='" + key + "'",
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:beginTransaction, endTransaction, replace, setTransactionSuccessful
 
	public void replace(int id, String type, int bonus) {
		l.trace("replace"); 
		SQLiteDatabase DB = getWriteDB();
		try { 
			DB.beginTransaction();
			ContentValues values = new ContentValues();
			values.put(ID, id);
			values.put(ARMOR, type);
			values.put(BONUS, bonus);
			DB.replace(TABLENAME, null, values);
			DB.setTransactionSuccessful();
		} finally { 
			DB.endTransaction();
		} 
	} 
 
	public String getArmorType(int getID) {
		l.trace("getArmorType"); 
		String[] cols = { ARMOR };
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:isOpen, replace
    public LoggerDbAdapter(Context ctx) {
        this.mCtx = ctx;
    } 
 
    public LoggerDbAdapter open() throws SQLException { 
        if (mDb != null && mDb.isOpen())
            return this;
        if (mDbHelper == null)
            mDbHelper = new DatabaseHelper(mCtx);
        try { 
            if (mDb == null)
                mDb = mDbHelper.getWritableDatabase();
        } catch (IllegalStateException ise) {
            Logger.LogError("Couldn't open logger", ise);
        } 
        return this;
    } 
 
    public void close() { 
        if (mDb != null && mDb.isOpen())

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:replace
        values.put(HISTORY_ORDER_ID_COL, orderId);
        values.put(HISTORY_PRODUCT_ID_COL, productId);
        values.put(HISTORY_STATE_COL, state.ordinal());
        values.put(HISTORY_PURCHASE_TIME_COL, purchaseTime);
        values.put(HISTORY_DEVELOPER_PAYLOAD_COL, developerPayload);
        mDb.replace(PURCHASE_HISTORY_TABLE_NAME, null /* nullColumnHack */, values);
    } 
 
    /** 
     * Updates the quantity of the given product to the given value. If the 
     * given value is zero, then the product is removed from the table. 
     * @param productId the product to update 
     * @param quantity the number of times the product has been purchased 
     */ 
    private void updatePurchasedItem(String productId, int quantity) {
        if (quantity == 0) {
            mDb.delete(PURCHASED_ITEMS_TABLE_NAME, PURCHASED_PRODUCT_ID_COL + "=?",
                    new String[] { productId });
            return; 
        } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:replace
	public void updateFilter(final JiraFilter filter) {
		final ContentValues cv = new ContentValues();
		cv.put("name", filter.getName());
		cv.put("id", filter.getId());
 
		this.mDB.replace("filters", "null", cv);
 
	} 
 
	public void updateResolution(final JiraResolution j) {
		final ContentValues cv = new ContentValues();
		cv.put("name", j.getName());
		cv.put("id", j.getId());
		cv.put("description", j.getDescription());
 
		this.mDB.replace("resolutions", "null", cv);
	} 
 
	public void updatePriority(final JiraPriority j) {
		final ContentValues cv = new ContentValues();
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:replace
This code example shows how to use the following methods:replace
  } 
 
  @Override 
  public Uri insert(Uri uri, ContentValues contentValues) {
 
    long id = database.replace(BUS_ROUTE_TABLE_NAME, null, contentValues);
    if (0 <= id) {
      Uri _uri = ContentUris.withAppendedId(CONTENT_URI, id);
      getContext().getContentResolver().notifyChange(_uri, null);
      return _uri;
    } 
    throw new SQLException("Failed to insert row into " + uri);
 
  } 
 
  @Override 
  public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    return database.query(BUS_ROUTE_TABLE_NAME, projection, selection, selectionArgs,
        null, null, sortOrder);
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:replace
 
		values.put("Config_Key", key);
		values.put("Config_Value", savedValue);
		values.put("Config_Description", desc);
 
		sqLiteDatabase.replace(TABLE, null, values);
	} 
 
	/** 
	 * 删除设置项 
	 * 
	 * @param name 
	 * @param value 
	 */ 
	public void delete(String key) {
		checkNull(key);
 
		SQLiteDatabase sqLiteDatabase = dbHelper.getWritableDatabase();
		StringBuilder sql = new StringBuilder();
		sql.append("DELETE FROM ").append(TABLE);
4
CodeRank
Experience pair programming with AI  Get Codota for Java

Related SQLiteDatabase replace Questions & Answers:

replace Method Overview
Convenience method for replacing a row in the database.
See Code Examples for other Android SQLiteDatabase Methods: