SQLiteDatabase insertWithOnConflict - 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 insertWithOnConflict method.

This code example shows how to use the following methods:close, insertWithOnConflict
        try { 
            ContentValues values = new ContentValues();
            values.put(C_ID, status.getStatusId());
            values.put(C_CREATED_TIME, status.getTime());
            values.put(C_MESSAGE, status.getMessage());
            db.insertWithOnConflict(TABLE, null, values, SQLiteDatabase.CONFLICT_IGNORE);
        } catch (Exception e) {
            // e.printStackTrace(); 
        } finally { 
            db.close();
        } 
    } 
     
    /** 
     *  
     * @return Cursor the status by desc order 
     */ 
    public Cursor getStatusUpdatesByDescOrder() 
    { 
        SQLiteDatabase db = dbHelper.getReadableDatabase();
5
CodeRank
This code example shows how to use the following methods:close, insertWithOnConflict
		values.put(AnnotationDBHelper.COLUMN_ANNOTATION_RIGHT, annotRect.right);
		values.put(AnnotationDBHelper.COLUMN_ANNOTATION_BOTTOM, annotRect.bottom);
		values.put(AnnotationDBHelper.COLUMN_ANNOTATION_TOP, annotRect.top);
 
		this.database = getWritableDatabase();
		this.database.insertWithOnConflict(AnnotationDBHelper.TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
		this.database.close();
	} 
 
	public void close() { 
		if (this.database != null) {
			this.database.close();
		} 
	} 
 
	public JSONObject getJSONAnnotation(LinkedList<AnnotatedImageDS> imageList) {
		JSONObject retObject = new JSONObject();
		JSONArray annotationArray = new JSONArray();
		for (int i = 0; i < imageList.size(); i++) {
			AnnotatedImageDS imageDS = imageList.get(i);
5
CodeRank
This code example shows how to use the following methods:insertWithOnConflict
This code example shows how to use the following methods:insertWithOnConflict
				lastPollTime = new Date(nodeDetail.getString("lastCapsdPoll"));
			} else { 
				lastPollTime = null ;
			} 
			values.put("lastpoll", lastPollTime==null?0:lastPollTime.getTime());
			if (db.insertWithOnConflict("nodes", null, values, SQLiteDatabase.CONFLICT_REPLACE)<0) {
				Log.e("ONMSDataAdapter","Failed to update row with the following data: "+nodeDetail.toString(4)) ;
			} 
		} catch (JSONException jsone) {
			Log.e("ONMSDataAdapter","JSONException occurred while trying to read node data.", jsone) ;
		} 
	} 
 
	/** 
	 * Return information about the node specified by nodeId 
	 * @param nodeId The numeric ID for the node to retrieve data for 
	 * @return A {@link JSONObject} containing the details about the specified node 
	 */ 
	public JSONObject getNodeById(long nodeId) {
		JSONObject node = new JSONObject() ;
4
CodeRank
This code example shows how to use the following methods:insertWithOnConflict
	private void insertTopicVideo(SQLiteDatabase tempDb, ContentValues values) {
		// This values is for a video. 
		ContentValues v = new ContentValues();
		v.put("topic_id", values.getAsString("parentTopic_id"));
		v.put("video_id", values.getAsString("readable_id"));
		tempDb.insertWithOnConflict(topicvideoTableName, null, v, SQLiteDatabase.CONFLICT_IGNORE);
	} 
	 
	private void insertVideo(SQLiteDatabase tempDb, ContentValues values) {
		tempDb.insertWithOnConflict(videoTableName, null, values, SQLiteDatabase.CONFLICT_IGNORE);
	} 
	 
	private void mergeDbs() { 
		Log.d(LOG_TAG, "update received - juggling dbs");
		// Get main database, attach temp db to it. 
		SQLiteDatabase mainDb = dataService.getHelper().getWritableDatabase();
		mainDb.execSQL("attach database ? as ka_temp", new Object[] {dataService.getDatabasePath("ka_temp").getAbsolutePath()});
		 
		mainDb.beginTransaction();
		try { 
3
CodeRank
This code example shows how to use the following methods:insertWithOnConflict
This code example shows how to use the following methods:insertWithOnConflict
		contentValues.put(KEY_ANSWER, answer.getAnswer());
		contentValues.put(KEY_CID, answer.getcId());
		contentValues.put(KEY_REVIEW, answer.getReview());
		contentValues.put(KEY_ITERATION, answer.getIteration());
		 
		db.insertWithOnConflict(ANSWER_TABLE, null, contentValues, SQLiteDatabase.CONFLICT_IGNORE);
	} 
	 
	public void deleteChapterAnswers(long chapterId) {
		db.delete(ANSWER_TABLE, KEY_CID + "=" + chapterId, null);
	} 
	 
	public void deleteChapterAnswers(long chapterId, long iterationId) {
		db.delete(ANSWER_TABLE, KEY_CID + "=" + chapterId + " AND " +
				KEY_ITERATION + "=" + iterationId, null);
	} 
	 
	public Cursor getReviewsByChapterId(long chapterId, long iterationId) {
		cursor = db.query(ANSWER_TABLE, null, KEY_CID + "=" + chapterId + " AND " + KEY_ITERATION
				+ "=" + iterationId, null, null, null, KEY_QID);
4
CodeRank

Related SQLiteDatabase insertWithOnConflict Questions & Answers:

insertWithOnConflict Method Overview
General method for inserting a row into the database.
See Code Examples for other Android SQLiteDatabase Methods: