删除日历条目
我编写了简单的代码来删除 Android 日历中的所有条目,但它没有删除任何内容。
源代码:
public void DeleteEvent(View view){
int iNumRowsDeleted = 0;
Uri eventsUri = Uri.parse("content://com.android.calendar/events");
Cursor cur = getContentResolver().query(eventsUri, null, null, null, null);
while (cur.moveToNext()){
long id = cur.getLong(cur.getColumnIndex("_id"));
Log.d(TAG, "ID: " + id);
Uri eventUri = ContentUris.withAppendedId(eventsUri, id);
iNumRowsDeleted = getContentResolver().delete(eventUri, null, null);
}
}
I wrote simple code for deleting all entries from android calendar,but it didn't delete nothing.
Source code:
public void DeleteEvent(View view){
int iNumRowsDeleted = 0;
Uri eventsUri = Uri.parse("content://com.android.calendar/events");
Cursor cur = getContentResolver().query(eventsUri, null, null, null, null);
while (cur.moveToNext()){
long id = cur.getLong(cur.getColumnIndex("_id"));
Log.d(TAG, "ID: " + id);
Uri eventUri = ContentUris.withAppendedId(eventsUri, id);
iNumRowsDeleted = getContentResolver().delete(eventUri, null, null);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我用它来删除:
我用这样的方式调用它:
I use this for delete:
I call it with something like this:
使用此代码是正确的
use this code its right