2013-11-21 39 views
0

在我的應用程序中,我需要從特定數量的短信到activity.I得到它。現在怎麼能區分讀取和未讀的具體數字的消息。而且我需要顯示未讀消息從我以前的activity.Can人,這個數字算出來將合計的消息告訴我怎樣才能完成這個任務?我想下面的代碼,如何區分讀取和未讀的消息

Cursor cur = getContentResolver().query(uri,new String[] { "_id", "thread_id", 
      "address", "person", "date","body", "type" },"read=0", null, null); 

但這回0排在listview.I也嘗試通過使用獲得消息總數

msgcount=list.size(); 

如何能我的msgcount價值爲我以前的活動。我將變量聲明爲public static。但它顯示爲0,而列表大小爲11.
請幫助!

+0

你可以使用行查詢 –

回答

0

未讀消息read=0有關詳細信息,請點擊此鏈接Get number of unread sms

+0

它會得到所有numbers.But我想要得到它針對特定的手機號碼未讀短信... – Jolly

+0

將查詢條件放在哪裏: - getContentResolver()。query(uri,new String [] {「_id」,「thread_id」,「address」,「person」,「date」,「body」,「type」},閱讀= 0「,放在哪裏條件,空); – Indra

+0

當我給讀= 0時,它只加載列表中的未讀消息...但我想加載讀取和未讀消息並區分它們... – Jolly

0
You can add sms_status flag as a column , it's default value 0 . 
when you will finish to read sms ,update flag and value will be 1. 

when you will query unread sms then check sms_status flag 0 and phone number 

msgcount=list.size(); 
if(msgcount > 0){ 

for(SMS sms:list){ 
String smsFlag = sms.getSmsFlag(); 
if(smsFlag .equals("0")){ 
// read sms 

}else{ 

//unread sms 
} 
} 
} 
+0

我需要一個查詢,將檢索總數和未讀消息count.Then只有我必須設置標誌來區分它們 – Jolly