gpt4 book ai didi

database - 安卓数据库: IllegalStateException issue

转载 作者:太空宇宙 更新时间:2023-11-03 13:39:17 24 4
gpt4 key购买 nike

我通过以下方式创建了 SQLite 数据库:

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);
...
}

我尝试通过调用以下方法来存储新条目:

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;
}

但 db.insert() 返回 -1(它不存储新条目)并返回 IllegalStateException:

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

有谁知道这里出了什么问题以及如何解决?

最佳答案

来自reference :

Multiple statements separated by ;s are not supported.

会不会是这个问题?

关于database - 安卓数据库: IllegalStateException issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1119802/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com