这是我的代码:
try {
myDB = this.openOrCreateDatabase(DB_PATH+"DatabaseName", MODE_APPEND, null);
ContentValues updateRating = new ContentValues();
updateRating.put("rating", 5);
myDB.update(TableName1, updateRating, "id=?", new String[] {Long.toString(1)});
ContentValues novotes = new ContentValues();
novotes.put("no_of_votes", 1);
myDB.update(TableName1, novotes, "id=?", new String[] {Long.toString(1)});
}
catch(Exception e) {
Log.e("Error", "Error", e);
} finally {
if (myDB != null)
myDB.close();
}
这是我得到的错误:
04-27 14:31:34.026: ERROR/Error(1560): Error
04-27 14:31:34.026: ERROR/Error(1560): android.database.sqlite.SQLiteException: error code 8: **attempt to write a readonly database**
04-27 14:31:34.026: ERROR/Error(1560): at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
04-27 14:31:34.026: ERROR/Error(1560): at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:55)
04-27 14:31:34.026: ERROR/Error(1560): at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1692)
04-27 14:31:34.026: ERROR/Error(1560): at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1622)
04-27 14:31:34.026: ERROR/Error(1560): at com.db.mak.DataBaseWork.onCreate(DataBaseWork.java:30)
04-27 14:31:34.026: ERROR/Error(1560): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
非常感谢一些快速的帮助...
答案 0 :(得分:0)
尝试在myDB.open()
myDB = this.openOrCreateDatabase