Code example for SQLException

Methods: printStackTrace

0
    public void onCreate(SQLiteDatabase db) {
        try { 
			db.execSQL("create table " + TABLE_NAME + " ( id integer primary key autoincrement, key text not null, value text not null)");
		} catch (SQLException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
		} 
    } 
 
    public void set(String key, String value) {
        try { 
			db.execSQL("INSERT INTO " + TABLE_NAME + "('key', 'value') values ('"
			        + key + "', '"
			        + value + "')");
		} catch (SQLException e) {
			ContentValues cv = new ContentValues();
			cv.put(key, value);
			db.update(TABLE_NAME, cv, "key", new String[] {key});
		} 
    }