我正在尝试添加更新方法来更新用户信息。 这是我的更新方法:
//updating sqlite database with the group name
public void updateUserGroup(String groupName) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_GROUP, groupName);
HashMap<String, String> user = getUserDetails();
String userID = user.get("uid");
System.out.println("User id is: " + userID);
db.update(TABLE_LOGIN, values, SQLiteHandler.KEY_UID + "=\"" + userID + "\"", null);
}
这是错误:
java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/cindyliu96.test/databases/android_api
at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55)
at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1545)
at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1522)
答案 0 :(得分:0)
如何打开数据库连接
db.open();
当您完成交易或查询时
db.close();