Before use
After use
Public void readmediamessage ()
{
// SMS Database Query
ContentResolver cr = getContentResolver ();
Cursor cursor = cr. query (Uri. parse ("content: // sms/inbox"), null, null,
Null, null );
/***************************/
String msg = "";
While (cursor. moveToNext ())
{
Int phoneColumn = cursor. getColumnIndex ("address ");
Int smsColumn = cursor. getColumnIndex ("body ");
Msg + = cursor. getString (phoneColumn) + ":"
+ Cursor. getString (smsColumn) + "\ n ";
String contact = getContactNameFromPhoneNum (this. getApplicationContext (), cursor. getString (phoneColumn ));
GetData (contact, cursor. getString (smsColumn ));
// GetData (cursor. getString (phoneColumn), cursor. getString (smsColumn ));
}
}
Public void readmediamessage ()
{
// SMS Database Query
ContentResolver cr = getContentResolver ();
Cursor cursor = cr. query (Uri. parse ("content: // sms/inbox"), null, null,
Null, null );
/***************************/
String msg = "";
While (cursor. moveToNext ())
{
Int phoneColumn = cursor. getColumnIndex ("address ");
Int smsColumn = cursor. getColumnIndex ("body ");
Msg + = cursor. getString (phoneColumn) + ":"
+ Cursor. getString (smsColumn) + "\ n ";
String contact = getContactNameFromPhoneNum (this. getApplicationContext (), cursor. getString (phoneColumn ));
GetData (contact, cursor. getString (smsColumn ));
// GetData (cursor. getString (phoneColumn), cursor. getString (smsColumn ));
}
}
[Java]
Public String getContactNameFromPhoneNum (Context context, String phoneNum)
{
String contactName = "";
ContentResolver cr = context. getContentResolver ();
Cursor pCur = cr. query (
ContactsContract. CommonDataKinds. Phone. CONTENT_URI, null,
ContactsContract. CommonDataKinds. Phone. NUMBER + "=? ",
New String [] {phoneNum}, null );
If (pCur. moveToFirst ())
{
ContactName = pCur
. GetString (pCur
. GetColumnIndex (ContactsContract. CommonDataKinds. Phone. DISPLAY_NAME ));
PCur. close ();
}
Return contactName;
}
From running snails