Sort android contacts with custom fields - android

I have list of contacts with custom fields. I can display them in ListView sorting them
with respect to Displayname, which is not a custom field.
I need to display those contacts ordered/sorted by Company name which is a custom field.
I want to know if it is possible through androids API or should I go with my own manual sorting approach?
Contact tables format for Company field is:
MIMETYPE as INFO_BASIC, and column is Data.DATA4
Thanks in advance.

If you have to do it yourself, which I think you may, I suggest a Schwartzian Transformation.

Related

Compare a list of String values Firebase RealTime Database

Lets assume I have a List of String (ex: List<String>). I want to match all the Strings in the List to a particular attribute already present in the Firebase Database. How do I achieve this, as the equalTo() query only accepts a single String. I also don't want to generate as many queries as the List size. Any help would be much appreciated.

Searching for contacts with smartface

I would like to show my users a list of their contacts with a phone number. I tried to create a filtered list using the getAll method, but I found it too slow.
So I would like to allow the user to search for a name, and then I would return the contacts who name match the query. Is this possible in smartface?
Yes, it is possible.
You can use a repeatbox object in order to list contacts, and use a dataset for binding of that repeatbox. And when you write the appropriate sql statement(select) into that dataset, it will work for search.
Or you can search google for some search algorithms and use one of them. For example, you can use an editbox object, or a searchbar objects, and when its text is changed you can call your search function.

Get all Contacts (Both from Phone and sim ) in a listview

I am a new developer .
I am making app in which i want all Contacts in a listView . Contact name as main item and number as subitem .
I do some but i can't to get all contact ( both from phone and sim ) .
How to get all contacts ??
how to set the name as main item and the number as subitem ??
please help . thanks in advance .
You need to query the ContactsContract database using a contentResolver.
You can then use a SimpleCursorAdapter to link this to your list view. There are quite a few examples of how to do this on the web if you search around, e.g.:
http://learnandroideasily.blogspot.co.uk/2013/03/how-to-access-contacts-in-android.html
Make sure you read up a bit on how the contacts are actually stored on Android as it is a slightly complicated 3-tier system:
http://developer.android.com/reference/android/provider/ContactsContract.html
Try this,
http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/
I hope this will help..
and if you need to store contact to listview..
first you store all values in arraylist.
and pass the arraylist to adapter.
Then you display the contacts using listview
Do query on ContactsContract.Contacts.CONTENT_URI like you can see here : get all contacts phone number.
And do some research on Google from your own :).
For the ListView, search a tutorial to create a ListView.

Select multiple object type with auto complete

I am looking for some help to find a powerfull way to allow selection of different List items.
My case is that i have for exemple a List profiles, List teams ... and i'd like to have an autocomplete input that will show, for exemple if i type Al, all Teams and Profiles objects having there member variable name begining by Al.
The result would be that i could get from the activity, on submit click performed, a List & a List containing all the objects who have been selected through the autocomplete form.
Also i'd like that the list offered to the user that match the chars he typed show the name and a picture (facebook like tag selection).
Obviously i am not asking for some code but at least some guidelines from experienced Android devs who know what to do and not to do to create this kind of thing.
Thanks
Loader are one of the best way to filter list. You init a loader which take the String constraint used for filter, the each time the user type, you update the constraint and restart your Loader.
If I suppose that all your object are cached in a SQLite database you can use a CursorAdapter, Cursor and CursorLoader.
You create the needed CursorLoader by filter the query with the content of the EditText.
If you're not familiar with CursorLoader there is the AsyncTaskLoader, with this you won't have the need of DB and to code a provider which can accept raw query. Your object in ListA, ListB, etc must inherits of common class (hum... DataThing maybe :-)), you concatenate the objects in a list then you can filter the list : What is the best way to filter a Java Collection?
That's for the data filtering. Now in order to display the data the way you want, you can display of list below the EditText field or create a custom component if you want a more advanced look.

Retrieving Database Information and Showing in ListView with Android

I am working on an Android app that will allow the user to see restaurants in the city I live in. I am storing each restaurants information (name, address, telephone, hours, category, website) in an SQLite database.
What I am trying to do is to create a SortByAlpha activity that will list the restaurants by name in alphetically-descending order.
I understand that I should be using a Cursor to do this but I can't find a half decent tutorial, all of the "tutorials" I find are a bunch of code with minimal explanation. How can I do this / Where can I find a good tutorial?
Use SimpleCursorAdapter, which bridges between Cursor and Adapter. Here is an example how to use it: http://developer.android.com/guide/topics/ui/binding.html
I would advise creating a "Restaurant" class that contains all the fields you will be listing. Then make your SQL call and specify "ORDER BY Name". Then create an ArrayList that can be fed to your custom list adapter! Also, if they were to somehow get out of order, just implement the "Comparable" interface for the Restaurant class and compare based on "Name" and then you can call Collections.sort(restaurantlist); to sort them in alphabetical order. I personally think ORDER BY is the easier way to go!

Categories

Resources