下段代码将所有短信放到sms数组中,uriSms为SMS 常用URI 中的一个。
sms = new ArrayList<Map<String, Object>>();
Cursor c = getContentResolver().query(uriSms, null, null, null,null);
while (c.moveToNext()) {
try {
item = new HashMap<String, Object>();
// Read the contents of the SMS;
for (int i = 0; i < c.getColumnCount(); i++) {
String strColumnName = c.getColumnName(i);
String strColumnValue = c.getString(i);
item.put(strColumnName, strColumnValue);
}
} catch (Exception e) {
Log.w("Exception:", e.getMessage());
}
sms.add(item);
}