Android的:如何访问使用SDK的SIM卡联系人表? [英] Android: how to access the SIM contact table using the SDK?

查看:236
本文介绍了Android的:如何访问使用SDK的SIM卡联系人表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用这个查询读取SIM卡中的联系人。

I am trying to use this query to read the contacts on the SIM.

            cur = managedQuery(Uri.parse("content://icc/adn")
                ,null
                ,null
                ,null
                ,null
                );

应用程序有READ_CONTACTS和WRITE_CONTACTS权限。然而,该查询返回一个例外。

The application has READ_CONTACTS and WRITE_CONTACTS permissions. Yet, the query returns an exception.

java.lang.NullPointerException
    at android.os.Parcel.readException(Parcel.java:1224)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:160)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
    at android.content.ContentProviderProxy.bulkQuery(ContentProviderNative.java:369)
    at android.content.ContentProviderProxy.query(ContentProviderNative.java:388)
    at android.content.ContentResolver.query(ContentResolver.java:202)
    at android.app.Activity.managedQuery(Activity.java:1502)
    at com.example.delirious.delirio.onCreate(delirio.java:38)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2544)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621)
    at android.app.ActivityThread.access$2200(ActivityThread.java:126)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4595)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    at dalvik.system.NativeStart.main(Native Method)

怎么了?

推荐答案

我用下面的code得到details..It工作正常的卡贴

i have used the following code to get the simcard details..It works fine

Uri simUri = Uri.parse("content://icc/adn");
        Cursor cursorSim    = this.getContentResolver().query(simUri, null, null,null, null);

         while (cursorSim.moveToNext()) {           
             listName.          add(cursorSim.getString(cursorSim.getColumnIndex("name")));
             listContactId.     add(cursorSim.getString(cursorSim.getColumnIndex("_id")));      
             listMobileNo.      add(cursorSim.getString(cursorSim.getColumnIndex("number")));
            }

下面的名字,_id,数量从卡贴表的列名

Here the name, _id, number are column names from the simcard table

这篇关于Android的:如何访问使用SDK的SIM卡联系人表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆