2011-11-07 80 views

回答

1

你可以嘗試這樣的事情(來獲得目標地址和SMS的身體):

private Cursor smsQuerty() { 
      Uri query_content_uri = Uri.parse("content://sms/sent"); 

     String[] projection = new String[] { "_id", "address", "body" }; 

     Cursor tCursor = getContentResolver().query(query_content_uri, 
       projection, null, null, null); 
     startManagingCursor(tCursor); 

        return tCursor; 
    } 

不是LOG光標看到的數據...例如:

private void logCursorForTesting(Cursor cursor) { 
    int colCount = cursor.getColumnCount(); 
    Log.d(TAG, "Column count is: " + colCount); 

    if (cursor != null && cursor.moveToFirst()) { 
     while(cursor.moveToNext()) { 
      for (int i = 0; i < colCount; i ++) { 
       Log.d(TAG, "## >> " + cursor.getString(i)); 
      } 
      Log.d(TAG, "---------------"); 
     } 
    } 
}