android - 将数据插入android中的sqlite数据库表时出错

标签 android sqlite

我有一个数据库表:

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 =>> 是打开的而不是只读的。

最佳答案

您正在尝试插入一个只读的数据库。

使用openDatabaseOPEN_READWRITE 标志代替。

关于android - 将数据插入android中的sqlite数据库表时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7577518/

相关文章:

Android:寻找一种方法来加速通过 wifi 从 Android 到 PC 的图像传输

android - 旋转屏幕时虚拟键盘不出现?

android - Sqlite replace() 用于替换多个字符

javascript - knex.js 迁移中的时间戳字段

c# - 短小精悍: "Insufficient parameters supplied to the command"

android - OkHttp 不断收到 StreamResetException : stream was reset: INTERNAL_ERROR when it's 200

android - 是否可以使用 Uri.Builder 而没有 "//"部分?

android - 使用 https ://fcm. googleapis.com/fcm/send 发送 Firebase 数据消息时注册无效?

bash - SQLite插入的bash循环错误

c - sqlite 增加返回的 blob 的大小