Skip to content Skip to sidebar Skip to footer

SQLiteDatabase Android IllegalStateException

i have a problem when i'm using the Sqlite of android. The log show me that : SQLiteConnectionPool(1730): **The connection pool for /data/data/dev.xx.xx/databases/XX has been close

Solution 1:

I don't believe you should be getting a new SQLiteDatabase instance like that every time. You want to keep a reference to the SQLiteDatabase object in your SQLiteOpenHelper. Your SQLiteOpenHelper should be constructed something more like the following:

public class DataBase extends SQLiteOpenHelper {

...
    private SQLiteDatabase mDatabase;

    @Override
    public void onCreate(SQLiteDatabase db) {
        ...
        mDatabase = db;
        ...
    }

    void addUser(String who, String time, String table, String phone) {
        ContentValues values = new ContentValues();
        values.put(KEY_NAME, who);
        values.put(KEY_PHONE, phone);
        values.put(KEY_TABLE_RES, table);
        values.put(KEY_TIME, time);
        mDatabase.insert(TABLE_RESERVATION, null, values);
    }

....
}

Post a Comment for "SQLiteDatabase Android IllegalStateException"