Code example for SQLiteDatabase

Methods: deletereplace

0
    public void setString(String name, String value)
    { 
        ContentValues cv = new ContentValues();
        cv.put("key", name);
        cv.put("value", value);
        mDatabase.delete("settings", "key='" + name + "'", null);
        mDatabase.replace("settings", null, cv);
    } 
     
    public String getString(String name)
    { 
        return getString(name, null);
    } 
 
    public String getString(String name, String defaultValue)
    { 
        Cursor cursor = mDatabase.query("settings", new String[] { "value" }, "key='" + name + "'", null, null, null, null);
        try 
        { 
            if (cursor.moveToNext())
                return cursor.getString(0);