Get SMS Details From its ID Android

前端 未结 1 1755
终归单人心
终归单人心 2021-01-06 14:26

I want to get Details of SMS(Number, Text Body, Time of coming); And i only know the id of sms. Can i query to \"content://sms\" with this id and get details?

At

相关标签:
1条回答
  • 2021-01-06 14:49

    I figure out my self but took me some time, Following code works for me:

            Uri myMessage = Uri.parse("content://sms/");
            ContentResolver cr = getContentResolver();
            Cursor c = cr.query(myMessage, new String[] { "_id", "address", "date", "body","read" },"_id = "+smsID, null, null);
    
            c.moveToFirst();
    
            String Number = c.getString(c.getColumnIndexOrThrow("address")).toString();
    
            String ReadStatus = c.getString(c.getColumnIndex("read"));
            String Body = c.getString(c.getColumnIndexOrThrow("body")).toString();
    
            c.close();
    

    I was missing the condition and moving the cursor to first. Hope someone could find it helpfull.

    0 讨论(0)
提交回复
热议问题