Read inbox messages of a particular number and display them in an activity

后端 未结 3 1835
一整个雨季
一整个雨季 2020-12-05 09:53

I am trying to read messages from an inbox and display them in an activity. My activity contains a button and listview. When I click on the button, all messages from the inb

3条回答
  •  抹茶落季
    2020-12-05 10:30

    add an if statement in your loop to match the selected number

    String selectedNumber;
    // copy the selected number to selectedNumber
    do {
            if(cursor.getString( indexAddr ).equals(selectedNumber))
            {
               String str = "Sender: " + cursor.getString( indexAddr ) + "\n" +     cursor.getString( indexBody );
               smsList.add( str );
            }
        }
    while( cursor.moveToNext() );
    

    Here only the messages from number matching the selected number will be added to smsList. It is an old question but i hope it will be helpful for someone

提交回复
热议问题