0

纽比在这里。我创建一个表。

public void onCreate(SQLiteDatabase db) {
      db.execSQL("CREATE TABLE if not exists producttable(id INTEGER PRIMARY KEY AUTOINCREMENT
            + "productidno"
            + " TEXT UNIQUE,"
            + "productname"
            + " TEXT,"
            + "productprice" + " TEXT,"
            + "t1" + " TEXT," //two added,  watch commas after "TEXT,"
            + "t2" + " TEXT)");
}

当我尝试添加一个非唯一的 productidno 时,没有添加该行,但是程序继续,没有消息,什么都没有。我希望出现一个 toast,告诉用户未添加非唯一条目,以便他们知道并需要更改为唯一 productidno。我不知道把这个放在哪里。任何有关示例代码的帮助将不胜感激。谢谢,吉姆

4

1 回答 1

0

如果您使用SQLiteDatabase.insert()read in the docs about the return value。

于 2013-07-27T07:45:46.890 回答