3

我想从 sim 和 4.0 及更高版本的电话中获取所有联系人,但使用电话类型。我看到了这个链接How to get all contacts from phonebook & SIM card in Android?

但我没有得到联系类型。

4

1 回答 1

3

当我为 SIM CONTACTS 获取 CURSOR 时,它给了我 5 列字段,它们是name、number、extra_number、emails 和 _id在此处输入图像描述

因此,它实际上并没有为我们提供类似于电话联系人等 mime 类型字段的“联系人号码类型”字段。

可能有可能,如果是的话,如果其他人可以完成这个。

我已经发布了我在我的应用程序中使用的代码。

尝试{字符串 m_simPhonename = null; 字符串 m_simphoneNo = null;

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

                Log.i("PhoneContact", "total: "+cursorSim.getCount());

                while (cursorSim.moveToNext()) 
                {      
                    m_simPhonename =cursorSim.getString(cursorSim.getColumnIndex("name"));
                    m_simphoneNo = cursorSim.getString(cursorSim.getColumnIndex("number"));

                    m_simphoneNo.replaceAll("\\D","");
                    m_simphoneNo.replaceAll("&", "");
                    m_simPhonename=m_simPhonename.replace("|","");

                    Log.i("PhoneContact", "name: "+m_simPhonename+" phone: "+m_simphoneNo);

                    if(m_simphoneNo.length()>0){
                        if(m_simPhonename!=null){

                        }else{
                            m_simPhonename = m_simphoneNo;
                        }
                        callbackDB.InsertContacts(null, m_simPhonename+"="+m_simphoneNo, m_simphoneNo, null);
                    }
                }     
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
于 2013-08-07T12:00:28.350 回答