“No Such Table” Error found in SQLite Android

前端 未结 10 2078
轮回少年
轮回少年 2020-12-06 11:12

I am trying to learn about SQLite databases, but I really hate dealing with any back-end stuff, with a passion. I\'m already hitting walls with a seemingly simple problem. <

相关标签:
10条回答
  • 2020-12-06 11:56

    There is an older version of the database on your device, which does have the (empty) database in place, but not the books table. If that's an option for you, just uninstall and reinstall the app.

    Later, when you'd like to add a new table to the database during production on end-user devices, but keep existing data, the designated hook to add new tables, alter the schema or upgrade your data is the onUpgrade method of your SQLiteOpenHelper.

    0 讨论(0)
  • 2020-12-06 11:58

    I have written a ORM framework for that. https://github.com/ahmetalpbalkan/orman

    You can easily write Android applications using SQLite with that. It uses your Java classes (Book, in this case) as database tables (entities).

    It even creates your table automatically and you just say book1.insert(), done.

    0 讨论(0)
  • 2020-12-06 11:58

    You must uninstall the applcation and then reinstall it. It should work after that.

    0 讨论(0)
  • 2020-12-06 11:58
    db.execSQL(
        "CREATE TABLE " + TABLE_NAME + " (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, author TEXT, isbn TEXT)"
    );
    

    remove space after the table name, it should be like this.

    db.execSQL(
        "CREATE TABLE " + TABLE_NAME + "(id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, author TEXT, isbn TEXT)"
    );
    
    0 讨论(0)
提交回复
热议问题