Code example for SQLiteDatabase

Methods: insertrawQueryupdate

1
            cvs.put("bg_color", background);
            cvs.put("marked_text_color", markedText);
            cvs.put("marked_bg_color", markedBackground);
            Long id = this.id;
            if (id != null) {
                db.update("styles", cvs, "_id = ?", new String[] { id.toString() });
            } else { 
                id = db.insert("styles", null, cvs);
            } 
            Cursor cursor = db.rawQuery("SELECT * FROM styles WHERE _id = ?",
                    new String[] { id.toString() });
            try { 
                if (cursor.moveToFirst()) {
                    return new Style(cursor);
                } else { 
                    return null; 
                } 
            } finally { 
                cursor.close();
            }