android自带数据库查询
程序员文章站
2024-01-13 18:16:58
...
1、通话记录表
Cursor cursor = context.getContentResolver().query(CallLog.Calls.CONTENT_URI, new String[] {CallLog.Calls._ID, CallLog.Calls.NUMBER, CallLog.Calls.CACHED_NAME, CallLog.Calls.DATE, CallLog.Calls.TYPE, "count(number) as totalCount"}, "1=1) group by " + CallLog.Calls.NUMBER + " order by date desc" + "--(", null, null);
2、短信表
Cursor cursor = context.getContentResolver().query(Uri.parse("content://sms"), new String[] {"_id,address,date,read,status,type,body,count(address) as " + "totleCount from (select _id,substr(address,4) as address,date,read,status,type,body " + "from sms where address like \"+86%\" union select _id,address,date,read,status,type,body " + "from sms where address not like \"+86%\") r group by r.address order by r.date desc --"}, null, null, null);
3、短信列表
AsyncQueryHandler asyncQuery; asyncQuery.startQuery(1, null, uri, projection, "address = ? or address = ?", selectionArgs, "date asc"); private class MsgAsyncQueryHandler extends AsyncQueryHandler { @Override protected void onQueryComplete(int token, Object cookie, Cursor cursor) { //0: all 1:收件箱 2: 已发送 3: 草稿 4:发件箱 5:失败 6:待发送 } }
上一篇: Linux 系统性能分析工具 sar
下一篇: 如何获取java新IO的Path文件大小