當前位置:名人名言大全網 - 短信平臺 - android系統的短信快捷查詢如何實現。(代碼)

android系統的短信快捷查詢如何實現。(代碼)

獲取會話列表

public static Cursor queryAll(Context context)

{

// Cursor cur = context.getContentResolver().query(CONTENT_URI, PROJECTION,

// "length(snippet)>0", null, null);

Cursor cur = context.getContentResolver().query(Uri.parse("content://sms"),

new String[] {"thread_id,date,address,read,status,type,body,count(address) as "

+ "totleCount,_id from (select thread_id,_id,substr(address,4) as address,date,read,status,type,body "

+ "from sms where address like \"+86%\" and length(thread_id)>0 union select thread_id,_id,address,date,read,status,type,body "

+ "from sms where length(thread_id)>0 and address not like \"+86%\") r group by r.thread_id order by r.date desc --"},

null,

null,

null);

return cur;

}

獲取某個會話所有內容

public static void asyncQueryAll(AsyncQueryHandler handler, int token,String thread_id)

{

handler.cancelOperation(token);

ThreadID=thread_id;

handler.startQuery(token, null, SMS_URI_ALL, PROJECTION,sql,new String[]{thread_id},"date desc");

}