“No Such Table” Error found in SQLite Android

前端 未结 10 2102
轮回少年
轮回少年 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:40

    try this one for example for insert:

     public boolean insertBook(String title, String author, String isdn) {
    
            try {
                SQLiteDatabase db = getWritableDatabase();
    
                ContentValues cv = new ContentValues();
                cv.put(TITLE, title);
                cv.put(AUTHOR, author);
                cv.put(ISBN, isdn);
    
                ***try
                 {
                db.insert(TABLE_NAME, null, cv);
    }
     catch ( SQLiteException e)
            {
                onCreate(db);
      db.insert(TABLE_NAME, null, cv);
    }***
    
                db.close();
    
                return true;
            } catch (Exception exp) {
                exp.printStackTrace();
    
                return false;
            }
        }
    

提交回复
热议问题