This is my code:
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();
}
This is the error i am getting:
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)
Would really appreciate some quick help...
Try to add myDB.open()
after myDB = this.openOrCreateDatabase
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.