`
zhuqiang1002
  • 浏览: 11590 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

android自带数据库查询

 
阅读更多

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:待发送                
    }
}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics