Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7610441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:25:08+00:00 2026-05-31T01:25:08+00:00

String tmp = txtPhoneName.getText().toString(); ContentResolver cr = getContentResolver(); Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, DISPLAY_NAME

  • 0
String tmp = txtPhoneName.getText().toString();
ContentResolver cr = getContentResolver(); 
Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null,  "DISPLAY_NAME = '" + tmp + "'", null, null);

if (cursor.moveToFirst()) {     
    String contactId = Cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
    Cursor phones = cr.query(Phone.CONTENT_URI, null, Phone.CONTACT_ID + " = " + contactId, null, null); 

    while (phones.moveToNext()) {   
        String number = phones.getString(phones.getColumnIndex(Phone.NUMBER));
        number1 = number;
        int type = phones.getInt(phones.getColumnIndex(Phone.TYPE));  

        switch (type) {    
            case Phone.TYPE_HOME: 
            // do something with the Home number here...  
                break;          
            case Phone.TYPE_MOBILE:    
                // do something with the Mobile number here...   
                break;            
            case Phone.TYPE_WORK:   
                // do something with the Work number here... 
                break;           
        }   
    }    
    phones.close();
}

My issue is that when it is at the switch statment it doesn’t check anything. It goes to the while(phones.moveToNext()) where is my error does Phone.TYPE_HOME is not int and my type can’t compare to it… And one last question, why for some contacts it gets the mobile number and for others the home (and in both cases the contacts have a home and a mobile number)? I want to get a number that starts with 07 and if there is no that kind of number to get whatever number there is for the contact, and then how to call that number… THX

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:25:09+00:00Added an answer on May 31, 2026 at 1:25 am

    It is probably because u haven put anything yet in the cases, try with int i=0; and see in the debugger

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in the following code : var benq:Base64Encoder = new Base64Encoder(); benq.encode(force,0,5); var tmp:String =
I'm trying to initialize string with iterators and something like this works: ifstream fin(tmp.txt);
int main(void) { char tmp, arr[100]; int i, k; printf(Enter a string: ); scanf_s(%s,
Given the following code: String tmp = new String(\\u0068\\u0065\\u006c\\u006c\\u006f\\u000a); String result = convertToEffectiveString(tmp); //
I have a string var in my Struts2 action, like this: String tmp =
public ArrayList<HashMap<String,String>> c_tmp= new ArrayList<HashMap<String,String>>(); public HashMap<String,String>mapa=new HashMap<String, String>(); String[] name_Val = null; //i
I was wandering which is best to do: string tmp = Directory.GetCurrentDirectory(); string path
What do I do wrong here? string tmp = @ if (UseImageFiles) { vCalHeader
I have a loop like: String tmp; for(int x = 0; x < 1000000;
final String [] tmp = new String[]{Android, Google}; ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(getApplicationContext(),android.R.layout.simple_expandable_list_item_1,tmp); final

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.