I want to read the sms from inbox and display them in a list view with few sms content providers like id,sender number,body,time.
Rite now Im able to read the sms and display in list view only the body of the sms but in need to display other field too.
I am using Android Studio for app development.
Here is a code which i can displays the body of sms in listview
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, android.R.id.text1, messageArray);
lv.setAdapter(adapter);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
});
public ArrayList<String> readAllData() {
ArrayList<String> sms = new ArrayList<>();
Uri us = Uri.parse("content://sms/inbox");
cr = getContentResolver().query(us, null, null, null, null);
String body = cr.getString(cr.getColumnIndexOrThrow("body"));
sms.add(body);
return sms;
}
I wanted to display Sms id, sender name and time. Please can anybody could help me out...