SQLite入门之读取手机短信

在activity_main.xml中添加以下代码来触发查询短信事件:

SQLite入门之读取手机短信_第1张图片

在MainActivity.java中添加以下内容:

public void querySMS(View view){
    ContentResolver cr  = this.getContentResolver();
    Cursor cursor  = cr.query(Uri.parse("content://sms"),new String []{"address","date","body","type"},null,null,"date desc");
    while(cursor.moveToNext()){
        String address = cursor..getString(0);
        String date =cursor.getString(cursor.getColumIndex("date"));
        String body = cursor.getString(4);
        String type = cursor.getString(3);
        Log.i("test","address:"+address+",date:"+date+",body:"+body+",type:"+type);
    }
}

SQLite入门之读取手机短信_第2张图片

你可能感兴趣的:(linux,android,sqlite)