Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
检索存储在Android中的我自己的个人资料信息_Android_Android Contacts - Fatal编程技术网

检索存储在Android中的我自己的个人资料信息

检索存储在Android中的我自己的个人资料信息,android,android-contacts,Android,Android Contacts,我正在尝试检索手机中为我的帐户存储的姓名和电子邮件地址。我尝试了以下方法: Cursor c = this.getContentResolver().query(ContactsContract.Profile.CONTENT_URI, null, null, null, null); int count = c.getCount(); String[] columnNames = c.getColumnNames(); boolean b = c.moveToF

我正在尝试检索手机中为我的帐户存储的姓名和电子邮件地址。我尝试了以下方法:

    Cursor c = this.getContentResolver().query(ContactsContract.Profile.CONTENT_URI, null, null, null, null);
    int count = c.getCount();
    String[] columnNames = c.getColumnNames();
    boolean b = c.moveToFirst();
    int position = c.getPosition();
    if (count == 1 && position == 0) 
    {
        String columnValue = null;
        for (int j = 0; j < columnNames.length; j++) 
        {
            String columnName = columnNames[j];
            columnValue = c.getString(c.getColumnIndex(columnName));
            Log.e("Name:", "Value" + columnValue);
        }

    }
    c.close();
和权限:

<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
上面记录了很多原始数据,包括我的名字,但我无法从中检索到我的名字

还有一件事我怎样才能得到我的电子邮件地址呢

让我知道


谢谢

如果您想获取电子邮件地址或其他条目,请尝试使用ContactsContract.Profile.CONTENT\u原始\u CONTACTS\u URI,而不是ContactsContract.Profile.CONTENT\u URI。

我得到了相同的结果。.数组中有大量垃圾邮件详细信息。我如何从中选择特定的名称?我之前对此感到困惑,并提取了contact db文件来调查里面发生了什么。你可以试一试。在这个意义上联系DB?