我有一个数据库表:
create table recentMovies5 (_id integer primary key autoincrement, line1 text, line2 text, title text , Tags text , ImageLink text , XMLLink text, entryTime numeric);
并且正在插入这样的值:
Insert into recentMovies5 (line1, line2, title, Tags,ImageLink,XMLLink,entryTime) Values ("3 min ", "Japan", "Ahsan", "38", "www.ahsan.com/aha.jpg", "www.ahsan.com/aha.xml",1317172213);
插入java代码:
String select="Insert into recentMovies5 (line1, line2, title, Tags,ImageLink,XMLLink,entryTime) Values (\"3 min \", \"Japan\", \"Ahsan\", \"38\", \"www.ahsan.com/aha.jpg\", \"www.ahsan.com/aha.xml\",1317172213)";
SQLiteDatabase db = savedInfoDbHelper.getReadableDatabase();
Cursor c=db.rawQuery(select, null);
startManagingCursor(c);
在我添加 entryTime numeric
列之前,一切正常。现在,没有数据被插入,我也没有收到任何错误信息!有什么帮助吗?
编辑 1:将 entryTime 从 numeric
更改为 integer
似乎没有帮助:(
编辑 2:使用此代码打开数据库:
public SavedMoviesDbAdapter open() throws SQLException {
dbHelper = new RecentMovieDatabaseHelper(context);
database = dbHelper.getWritableDatabase();
return this;
}
编辑 3:同时检查 isOpen 和 isReadOnly =>> 是打开的而不是只读的。
最佳答案
您正在尝试插入一个只读的数据库。
使用openDatabase用 OPEN_READWRITE
标志代替。
关于android - 将数据插入android中的sqlite数据库表时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7577518/