jeudi 30 avril 2015

Android SQLITE Illegal State Exception [duplicate]

This question already has an answer here:

I am using the following code to add items to the Database :

public static void insertQuestion(Context c,JSONArray jarr,String search) throws JSONException {
        DatabaseWrapper databaseWrapper = new DatabaseWrapper(c);
        SQLiteDatabase database = databaseWrapper.getWritableDatabase();
        ContentValues values = postToContentValues2(jarr);
        values.put(QuestionORM.COLUMN_SEARCH,search);
        long questionId = database.insert(QuestionORM.TABLE_NAME, "null", values);
        Log.e(TAG, "Inserted new Question with ID: " + questionId);
        database.close();
    }

But I get an error saying

"attempt to re-open an already-closed object"

on this line :

SQLiteDatabase database = databaseWrapper.getWritableDatabase();

How do I resolve this ?

Thanks !

Aucun commentaire:

Enregistrer un commentaire