質問

I want to get all the contacts from sim as well as phone in 4.0 and above ,but with phone type. I saw this link How to get all contacts from phonebook & SIM card in Android?

But i am not getting contact type.

役に立ちましたか?

解決

When I fetch CURSOR for SIM CONTACTS, it gives me 5 columns fields which are name, number, extra_number, emails and _id. enter image description here

So it is actually not providing us the field for "type of contact number" similar to mime-type field like phone contacts.

Might be it possible, if yes please, if someone else can complete this.

I have posted my code which I am using in my application.

try{ String m_simPhonename = null; String 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();
            }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top