• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How to select messages from a specific phone number (Kotlin Android)

Amir Elahi

Lurker
Aug 23, 2023
2
0
Code:
val cursor = contentResolver.query(Uri.parse("content://sms/inbox"), null, null, null, null)
if (cursor != null) {
        //cursor.moveToFirst()
        cursor.moveToPosition(1)

        var text = cursor.getString(12)
        Toast.makeText(applicationContext,text,Toast.LENGTH_SHORT).show()
    }

1- I want to read received messages from "50004000151398" only (not all inbox)

2- I want to see how many messages I have received from "50004000151398"

What should I do?

(I did not understand the current answers)
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones