Get SMS of specific phone number

后端 未结 3 1132
独厮守ぢ
独厮守ぢ 2020-12-10 18:50

I am wondering, how can I read sms message for a specific number programmatically? I know how to read sms using content provider but not sure if I should use the \"person\"

3条回答
  •  Happy的楠姐
    2020-12-10 19:09

    You may use SelectionArgs to be more efficient:

    String[] phoneNumber = new String[] { "+18839494492" }; //the wanted phone number
    Cursor cursor1 = getContentResolver().query(Uri.parse("content://sms/inbox"), new String[] { "_id", "thread_id", "address", "person", "date","body", "type" }, "address=?", phoneNumber, null);
    

    With this change you only get the sms from the wanted number and you have not to crawl through all received SMS.

提交回复
热议问题