我正在使用Android Marshmallow。我试图在草稿中保存短信,但它没有得到保存。我使用了以下代码:
ContentValues values = new ContentValues();
values.put("address", edphone_no.getText().toString());
values.put("body", edTextmsg.getText().toString());
values.put("date", String.valueOf(System.currentTimeMillis()));
values.put("type", "3");
values.put("thread_id", "0");
getContentResolver().insert(Uri.parse("content://sms/draft"), values);
在Manifest.xml
权限中声明:
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
获取草稿短信的代码:
Uri draftURI = Uri.parse("content://sms/draft");
String[] reqCols = new String[] { "_id", "address", "body" };
ContentResolver cr = getContentResolver();
Cursor c = cr.query(draftURI, reqCols, null, null, null);