区分SQLite中的更新和插入

时间:2013-04-01 10:42:24

标签: android sqlite

在SQlite中如何判断是否存在行更新它还是createEntry? 基本上我想要一个单行表,并在按下单个按钮时更新它。

entry.open();
if(the row already exist)
entry.updateContact(1, Double.toString(db1), Double.toString(db2), Double.toString(db3));
else
entry.createEntry(Double.toString(db1), Double.toString(db2), Double.toString(db3));
entry.close();

1 个答案:

答案 0 :(得分:0)

听起来像是INSERT OR REPLACE。在http://www.buzzingandroid.com/2013/01/sqlite-insert-or-replace-through-contentprovider/

上有关于此主题的博客文章