使用ContentProvider查看系统短信,首先要知道系统短信的数据文件在哪,在Android Studio中单击Device File Explorer,在目录中选择data/user_de/0/
com.android.roviders.telephony/databases目录下的mmssms.db文件中,与短信有关的是sms表,_id表示短信主键,address表示发送接收短信的手机号码,body表示短信内容
布局文件
<?xml version="1.0" encoding="utf-8"?><RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/sms"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="读取到系统信息如下: