【问题标题】:How can i access to all the message ( sms ) folder in the phone ?如何访问手机中的所有消息 (sms) 文件夹?
【发布时间】:2011-11-07 19:59:40
【问题描述】:

我编写了一些简单的应用程序,它会根据一些常规表达式查找一些消息(短信)。

我无法访问邮件文件夹 - 我该怎么做?

【问题讨论】:

    标签: android


    【解决方案1】:

    您可以尝试这样的事情(获取目标地址和短信正文):

        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;
        }
    

    比记录你的光标来查看数据...例如:

    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, "---------------");
            }
        }   
    }
    

    【讨论】:

      【解决方案2】:

      您需要使用内容提供程序来访问 android 上的短信。

      以下问题帮助您了解如何查询。

      Android 1.5: Reading SMS messages

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-09-26
        • 1970-01-01
        • 2015-10-21
        • 2017-11-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多