Android Call Log and SMS Delete&nbs
来源:技术人生 责任编辑:栏目编辑 发表时间:2013-07-01 04:25 点击:次
Android Call Log and SMS Delete 电话记录和短信删除
文章分类:移动开发
Java代码
public class CallContentObserver extends ContentObserver {
private final static String strUriInbox = "content://call_log/calls";
private final static Uri uriCall = Uri.parse(strUriInbox);
private String phoneNum;
private Context context;
public CallContentObserver(Context context, String phoneNum, Handler handler) {
super(handler);
this.context = context;
this.phoneNum = phoneNum;
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
Cursor c = context.getContentResolver().query(uriCall,
new String[] { "_id", "number", "date" }, null, null, null);
if (c != null && c.moveToFirst()) {
String num = c.getString(1);
String id = c.getString(0);
if (num != null &&phoneNum!=null&& num.equals(phoneNum)) {
context.getContentResolver().delete(uriCall, "_id=" + id,
null);
}
// for(int i =0; i < c.getColumnCount(); i++)
// {
// String strColumnName = c.getColumnName(i);
// String strColumnValue = c.getString(i);
// Log.e("i", "i="+i);
// Log.e("strColumnName", "strColumnName="+strColumnName);
// Log.e("strColumnValue", "strColumnValue="+strColumnValue);
// }
c.close();
}
}
}
调用
Java代码
context.getContentResolver()
.registerContentObserver(
Uri.parse("content://call_log"),
&nb
Java代码
public class CallContentObserver extends ContentObserver {
private final static String strUriInbox = "content://call_log/calls";
private final static Uri uriCall = Uri.parse(strUriInbox);
private String phoneNum;
private Context context;
public CallContentObserver(Context context, String phoneNum, Handler handler) {
super(handler);
this.context = context;
this.phoneNum = phoneNum;
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
Cursor c = context.getContentResolver().query(uriCall,
new String[] { "_id", "number", "date" }, null, null, null);
if (c != null && c.moveToFirst()) {
String num = c.getString(1);
String id = c.getString(0);
if (num != null &&phoneNum!=null&& num.equals(phoneNum)) {
context.getContentResolver().delete(uriCall, "_id=" + id,
null);
}
// for(int i =0; i < c.getColumnCount(); i++)
// {
// String strColumnName = c.getColumnName(i);
// String strColumnValue = c.getString(i);
// Log.e("i", "i="+i);
// Log.e("strColumnName", "strColumnName="+strColumnName);
// Log.e("strColumnValue", "strColumnValue="+strColumnValue);
// }
c.close();
}
}
}
调用
Java代码
context.getContentResolver()
.registerContentObserver(
Uri.parse("content://call_log"),
&nb
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>