2
我在內容解析器的幫助下訪問所有收件箱中的郵件但現在問題是我想從收件箱中刪除多個郵件或單個郵件。我發現所有消息的刪除功能不是針對單個消息或多個消息。我將所有消息存儲在ArrayList中。 任何幫助將不勝感激。如何從Android的收件箱中刪除多條消息或單條消息?
我讀消息的代碼是: -
Uri uriSMSURI = Uri.parse("content://sms/inbox");
Cursor cur = getContentResolver().query(uriSMSURI , null, null, null,
null);
startManagingCursor(cur);
int size=cur.getCount();
if (cur.moveToFirst())
{
for(int i=0;i<size;i++)
{
InboxField tempInboxField = new InboxField();
tempInboxField.body = cur.getString(cur.getColumnIndexOrThrow("body"));
tempInboxField.protocol = cur.getString(cur.getColumnIndexOrThrow("protocol"));
tempInboxField.type =cur.getString(cur.getColumnIndexOrThrow("type"));
tempInboxField.status = cur.getInt(cur.getColumnIndexOrThrow("status"));
tempInboxField.address =cur.getString(cur.getColumnIndexOrThrow("address"));
String tempdate =cur.getString(cur.getColumnIndexOrThrow("date"));
tempInboxField.id = cur.getInt(cur.getColumnIndexOrThrow("_id"));
tempInboxField.person = cur.getString(cur.getColumnIndexOrThrow("person"));
Long timestamp = Long.parseLong(tempdate);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(timestamp);
Date finaldate = calendar.getTime();
tempInboxField.date = finaldate.toString();
arrayList.add(tempInboxField);
cur.moveToNext();
}
}
謝謝,我已經解決了我的問題,因爲它是。 –