Android的SQLite的插入或更新 [英] Android SQLite Insert or Update
问题描述
由于可以在文档中看到的语法,使插入或更新为:插入或更换成<表> (小于列>)VALUES(小于值>)
,我的问题是那里合并以下
as can be seen in the documentation the syntax to make insert or update is : INSERT OR REPLACE INTO <table> (<columns>) VALUES (<values>)
, my question is there any function that merge the following ?
public long insert (String table, String nullColumnHack, ContentValues values)
public int update (String table, ContentValues values, String whereClause, String[] whereArgs)
或它必须用prepared SQL语句并rawQuery?
or it has to be done with a prepared SQL statement and rawQuery?
什么是最好的做法,以做到在Android中插入或更新?
What's the best practices to do an insert or update in Android?
推荐答案
这是你的方法<一href="http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#insertWithOnConflict%28java.lang.String,%20java.lang.String,%20android.content.ContentValues,%20int%29">SQLiteDatabase.insertWithOnConflict().要了解它是指在SQLite的这个文件
this is your method SQLiteDatabase.insertWithOnConflict(). to understand what it does refer to this document on sqlite
这篇关于Android的SQLite的插入或更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!