Code example for SQLiteOpenHelper

Methods: getWritableDatabase

0
     * @param helper 
     * @return writable database or null if it failed to create/open 
     */ 
    protected SQLiteDatabase getWritable(SQLiteOpenHelper helper) {
        try { 
            return helper.getWritableDatabase();
        } catch (SQLiteException e1) {
            // Make second attempt 
            try { 
                return helper.getWritableDatabase();
            } catch (SQLiteException e2) {
                return null; 
            } 
        } 
    } 
 
    /** 
     * Get readable database 
     * 
     * @param helper 
     * @return readable database or null if it failed to create/open