Code example for ContentValues

Methods: containsKeygetAsStringput

0
    public Uri insert(Uri uri, ContentValues values) {
 
        if (values != null) {
            values = new ContentValues(values);
        } else { 
            values = new ContentValues();
        } 
 
        Long now = Long.valueOf(System.currentTimeMillis());
        values.put(Columns.CREATED, now);
//        if (!values.containsKey(Columns.TITLE) && values.containsKey(Columns.OCR_TEXT)) { 
//        	values.put(Columns.TITLE, Html.fromHtml(values.getAsString(Columns.OCR_TEXT)).toString()); 
//        } 
 
        SQLiteDatabase db = dbHelper.getWritableDatabase();
        db.beginTransaction();
        if (values.containsKey(Columns.PARENT_ID)){
        	//update child count of parent 
        	final String query = "UPDATE "+DBHelper.TABLE_NAME+ " set " + Columns.CHILD_COUNT + "=" + Columns.CHILD_COUNT + "+1 WHERE _id=" + values.getAsString(Columns.PARENT_ID); 
        	Log.i(TAG,query);
        	db.execSQL(query );
        } 
        long rowId = db.insert(DBHelper.TABLE_NAME, null, values);
        if (rowId > 0) {