linux|SQLite入门之读取手机短信

在activity_main.xml中添加以下代码来触发查询短信事件: linux|SQLite入门之读取手机短信
文章图片

在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); } }

【linux|SQLite入门之读取手机短信】linux|SQLite入门之读取手机短信
文章图片

    推荐阅读