先贴一下API文档的解释
public abstract int delete (Uri uri, String selection, String[] selectionArgs)
Implement this to handle requests to delete one or more rows. The implementation should apply the selection clause when performing deletion, allowing the operation to affect multiple rows in a directory. As a courtesy, call notifyChange()
after deleting. This method can be called from multiple threads, as described in Processes and Threads.
The implementation is responsible for parsing out a row ID at the end of the URI, if a specific row is being deleted. That is, the client would pass in content://contacts/people/22
and the implementation is responsible for parsing the record number (22) when creating a SQL statement.
Parameters
uri | The full URI to query, including a row ID (if a specific record is requested). |
---|---|
selection | An optional restriction to apply to rows when deleting. |
Returns
- The number of rows affected.
sqliteDatabase.execsql("insert into table(_id,_name,_num) values(?,?,?)",new String[]{id,name,num});
这句语句表示插入三个参数到表table中,以此类比,delete方法可能为
getContentResolver().delete(URI , "id=?,name=?,num=?",new String[]{id,name,num});
意思是什么就很明了了,适合判断多组数据同时满足的操作。