public class Mainactivity extends Appcompatactivity {
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
}
public void Onclick_bak (view view) throws IOException {
Content://sms Search new system all SMS URI
Uri uri=uri.parse ("content://sms");
Get access to content providers
Contentresolver Contentresolver=getcontentresolver ();
Querying data with Contentresolver
Cursor cursor=contentresolver.query (uri,new string[]{"Address", "date", "type", "Body"},null,null,null);
List<smsinfo> smsinfolist=new arraylist<smsinfo> ();
Cursor.movetonext () moves to the next line
while (Cursor.movetonext ()) {
String address=cursor.getstring (0);
Long Date=cursor.getlong (1);
int Type=cursor.gettype (2);
String body=cursor.getstring (3);
Smsinfo smsinfo=new Smsinfo (date,type,body,address);
Smsinfolist.add (Smsinfo);
}
End of Read data
Cursor.close ();
Backup
Smsutils.backupsms (Smsinfolist,this);
}
}
Provider--appcompatactivity