0

我想删除“TYPE=0”记录,我的代码:

cv.put(Call.NAME, titleString);
cv.put(Call.BUILD_NAME, "");
cv.put(Call.BUILD, build);
cv.put(Call.UNIT, unit);
cv.put(Call.ROOM, room);
cv.put(Call.TIME, date);
cv.put(Call.TYPE, 0);// 
cv.put(Call.DEVICETYPE, doordevicetype);
cv.put(Call.PHOTO, baos.toByteArray());
cv.put(Call.CONTACT_ID, 9999);

Uri contactUri, uriRet;
ContentResolver resolver = getContentResolver();
uriRet = resolver.insert(contactUri, cv);

所以我可以插入很多记录,一些记录Call.TYPE=0,一些Call.TYPE=1,所以我想全部删除 Call.TYPE=1。我的代码:

int a=getContentResolver().delete(Call.CONTENT_URI,  Call.TYPE +"=" +1, null);

但是该应用程序删除了所有记录,包括Call.TYPE=0。我不知道出了什么问题。添加,插入,更新记录都可以,但是删除一些记录没有效果,请您给点建议好吗?

4

1 回答 1

2

匹配 TYPE = 1 时使用此代码删除特定行...

 String[] selectionArgs=new String[]{String.valueOf(1)};
 // this is for which argument to match   with TYPE=1 and delete row

 String selection=""+TablenName.TYPE+"=?"; //  this is where condition 
 getContentResolver().delete( Call.CONTENT_URI, selection, selectionArgs);

 Note : just refer this [link][1]. its usefull to understand for , how delete are happening..
 [1]: http://www.w3schools.com/sql/sql_delete.asp
于 2013-07-29T07:46:39.707 回答