Get contacts in Android
-
I want to get the contact numbers in Android but as far as I found a tutorial, it puts out the number in ascending order, not in the order they appear in the contacts... How can I modify the code to obtain the numbers in the exact order from my contact list?? Cursor cursor = getContentResolver().query(Phone.CONTENT_URI, new String[]{Phone.NUMBER}, null,null, null); ArrayList <String> nr_formatat = new ArrayList <String> (); if (cursor != null) { while (cursor.moveToNext() == true) nr_formatat.add(cursor.getString( cursor.getColumnIndex(Phone.NUMBER))); }
-
Answer:
You're going about it the wrong way. You need to query the number against the CONTACT_ID or else you won't have any correspondence between the two. Take a look at http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/.
Madrugada at Stack Overflow Visit the source
Other answers
It depends on how your contacts are ordered in your contact list. Hit the menu button and tap on 'Display Options'. Other than that, you don't have enough information in your question to adequately answer it. From what I can see, you're going about it the wrong way. I would look over this example application. It fetches the contacts differently than you and will allow you to sort it however you want. http://developer.android.com/resources/samples/BusinessCard/src/com/example/android/businesscard/index.html
Trev
Related Q & A:
- How To Get Product Code Sygic Android?Best solution by help.sygic.com
- How to Sync Yahoo contacts with Android contacts?Best solution by Yahoo! Answers
- How do I do a HTTP GET in Java (android?Best solution by Stack Overflow
- How to get contacts using address book API in ios programming?Best solution by Stack Overflow
- How can I get contacts to display?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.