3

I created the SQLite database the following way:

private static final String DATABASE_CREATE = "create table " + DATABASE_TABLE_SETTINGS + " (" +
KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
KEY_NAME + " INTEGER UNIQUE not null, " +
VALUE + " TEXT not null);" + 

"create table " + DATABASE_TABLE_RECORDINGS + " (" +
KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
RECORDING_FILENAME + " TEXT UNIQUE NOT NULL, " +
RECORDING_TITLE + " TEXT NOT NULL, " +
RECORDING_TAGS + " TEXT, " +
RECORDING_LOCATION + " TEXT, " +
RECORDING_TIME + " TEXT);";

@Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DATABASE_CREATE);
...
}

I try to store a new entry by calling the following method:

public long insertRecordingInfo(String filename, String title, String tags, int privacyLevel, String location, String recordingTime){
    long res = -1;
    ContentValues recordingInfoParameters = new ContentValues();
    recordingInfoParameters.put(RECORDING_FILENAME, filename);
    recordingInfoParameters.put(RECORDING_TITLE, title);
    recordingInfoParameters.put(RECORDING_TAGS, tags);
    recordingInfoParameters.put(RECORDING_PRIVACY_LEVEL, privacyLevel);
    recordingInfoParameters.put(RECORDING_LOCATION, location);
    recordingInfoParameters.put(RECORDING_TIME, recordingTime);

    if(db != null){
        res = db.insert(DATABASE_TABLE_RECORDINGS, null, recordingInfoParameters);
    }
    return res;
}

but the db.insert() returns -1 (it doesn't store a new entry) and it returns an IllegalStateException:

java.lang.IllegalStateException: /data/data/dev.client.android/databases/clientDB.db SQLiteDatabase created and never closed

Does anyone know what's wrong here and how it could be fixed?

1 Answer 1

4

From the reference:

Multiple statements separated by ;s are not supported.

Could that be the problem?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.