Back to project page porter.
The source code is released under:
Copyright (c) 2014, Benjamin Damer All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...
If you think the Android project porter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.afqa123.porter; // w w w.j av a2s . c o m import java.util.ArrayList; import java.util.List; import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; public class SmsProvider { final static String CONTENT_SMS = "content://sms"; final static String[] COLUMNS_SMS = { "address", "date", "type", "body" }; public static List<Entry> readAll(final ContentResolver aResolver) { Cursor cursor = null; List<Entry> entries = new ArrayList<Entry>(); try { cursor = aResolver.query(Uri.parse(CONTENT_SMS), COLUMNS_SMS, null, null, null); if (cursor.moveToFirst()) { do { SmsEntry e = new SmsEntry(); e.setAddress(cursor.getString(cursor.getColumnIndex("address"))); e.setDate(cursor.getString(cursor.getColumnIndex("date"))); e.setType(cursor.getString(cursor.getColumnIndex("type"))); e.setBody(cursor.getString(cursor.getColumnIndex("body"))); entries.add(e); } while (cursor.moveToNext()); } } finally { if (cursor != null) { cursor.close(); } } return entries; } }