查询以及删除通话记录的内容
来源:互联网 发布:查商品价格的软件 编辑:程序博客网 时间:2024/05/17 03:54
/** 返回查询的数据以及最新数据,将其装入Map中 */
private Map<String, Long> getCallTimeByWhere(final String where) {
Map<String, Long> result = new HashMap<String, Long>();Long total = 0L;
/** 最后一次通话时长 */
Long latestTimeLen = 0L;
/** 最后一次通话时间 */
Long lastDate = null;
final Cursor cursor = getContentResolver().query(CallLog.Calls.CONTENT_URI,
new String[] {CallLog.Calls.DURATION, CallLog.Calls.DATE }, where, null,
CallLog.Calls.DEFAULT_SORT_ORDER);
startManagingCursor(cursor);
for (int i = 0; i < cursor.getCount(); i++) {
cursor.moveToPosition(i);
Long duration = 0L;
try {
duration = Long.parseLong(cursor.getString(cursor.getColumnIndex(CallLog.Calls.DURATION)));
Long date = Long.parseLong(cursor.getString(cursor.getColumnIndex(CallLog.Calls.DATE)));
if (lastDate == null || lastDate < date) {
lastDate = date;
latestTimeLen = duration;
}
} catch (Exception e) {
duration = 1L;
latestTimeLen = duration;
}
total += duration;
}
Log.i("liyong", "total=" + total + "latestTimeLen=" + latestTimeLen);
result.put("result", total);
result.put("latestTimeLen", latestTimeLen);
return result;
}
/** 删除通话记录中满足where条件的数据 */
public int deleteCallData(String where) {
return getContentResolver().delete(CallLog.Calls.CONTENT_URI, where, null);
}
调用方法:
String where = "type=1 or type=2"; //删除来电和去电
ClassName.deleteCallData(where);
String where = "type=1 or type=2";
Map<String, Long> totleResult = ClassName.getCallTimeByWhere(where);
- 查询以及删除通话记录的内容
- 通话记录的查询与删除
- android 通话记录的查询与删除
- android 通话记录的查询与删除
- android 通话记录的查询与删除
- android 通话记录的查询与删除
- android通话记录的查询与删除
- android删除和查询通话记录
- Android之通话记录的查询、删除与插入(1)
- 删除联系人的通话记录
- 查询手机的通话记录
- Android - 利用内容提供者删除通话记录
- 删除通话记录
- 内容提供者的使用(消除通话记录)
- wince 通话记录的自动删除实现
- android删除某个号码的通话记录
- 怎么查询老婆的通话记录?QQ1622863529
- 怎么查询老公的通话记录?QQ1622863529
- 转载:Application的使用
- 当删除操作时,提示用户是否进行操作
- MTK note
- JS通过URL传递参数时出现乱码的处理
- 使用sqoop将MySQL数据库中的数据导入Hbase (转)
- 查询以及删除通话记录的内容
- SVN Ubuntu搭建
- mfcs42ud.pdb
- JNI Functions
- 线程同步工具类——CountDownLatch
- socket异步编程--libevent的使用
- Java数组与容器类分析资料–数组、List和Set、Map等
- 新版linux系统设备架构中关于电源管理方式的变更
- 六个建议防止SQL注入式攻击