How to use SMS content provider? Where are the docs?

后端 未结 7 1434
耶瑟儿~
耶瑟儿~ 2020-11-29 19:32

I\'d like to be able to read the system\'s SMS content provider. Basically I wanted to make an SMS messaging app, but it would only be useful if I could see past threads etc

7条回答
  •  孤独总比滥情好
    2020-11-29 19:52

    In addition to those u can see the list of fields in sms content provider by using following code:

    private void displaySmsLog() {
        Uri allMessages = Uri.parse("content://sms/");
         //Cursor cursor = managedQuery(allMessages, null, null, null, null); Both are same
        Cursor cursor = this.getContentResolver().query(allMessages, null,
                null, null, null);
    
        while (cursor.moveToNext()) {
            for (int i = 0; i < cursor.getColumnCount(); i++) {
                Log.d(cursor.getColumnName(i) + "", cursor.getString(i) + "");
            }
            Log.d("One row finished",
                    "**************************************************");
        }
    
    }
    

提交回复
热议问题