I am developing an application that accesses message history (SMS) in the inbox and outbox. What happens is that I can obtain data such as the date or the type of message (sent, received) but I have NOT been able to make reference to the NAME of the contact who did any of these actions.
Here is the code with which I get the output tray:
private void Cargando() {
Uri callUri = Uri.parse("content://sms/sent");
Cursor managedCursor = getContentResolver().query(callUri, null, null, null, null);
int number = managedCursor.getColumnIndex(Telephony.Sms.ADDRESS);
int date = managedCursor.getColumnIndex(Telephony.Sms.DATE);
int type = managedCursor.getColumnIndex(Telephony.Sms.TYPE);
while (managedCursor.moveToNext()) {
String phNumber = managedCursor.getString(number);
String fecha = (String) DateFormat.format("dd/MM/yy k:mm",managedCursor.getLong(date));
String tipo = managedCursor.getString(type);
Toast.makeText(getApplicationContext(), phNumber + fecha + tipo, Toast.LENGTH_SHORT).show();
}
}
I hope you can help me, Thanks!