Android Call Log and SMS Delete 电话记录和短信删除
2010-07-19 23:02:00 来源:WEB开发网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 && 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();
}
}
}
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;
更多精彩
赞助商链接