【发布时间】:2015-03-22 04:37:22
【问题描述】:
我正在尝试写入数据库,在我的规范中,我必须确保特定字段没有重复项。伟大的!我可以让专栏独一无二。
但我不知道之后如何处理。如果我使用该应用程序并意外插入了一个恰好已经存在的新值,则该应用程序将崩溃。在尝试更新数据库之前,如何检查该值是否已经存在?
我觉得 if 命令可以工作,Buuuuut,无论如何,你如何扫描 android 上该列的每个值?
【问题讨论】:
-
If I use the application and accidentally insert a new value which happens to already exist, the app will just crash.问:您如何处理错误? 答: 使用try ... catch [... finally]
标签: android database sqlite unique