android內建資料庫查詢

來源:互聯網
上載者:User

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

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.