5

I would like to know when to use each Adapter. According to my experience, and this article BaseAdapters are useful when I am getting data from an API for example, and I store it in a Collection object. However a CursorAdapter is used to query contents from a database, phone agenda...In general, contents which have also a content provider to query the info out of them.

So basically a BaseAdapter is used to queries that dont have a content provider to access them, because in that case a CursorAdapter will be the best choice. Is that right?

Dayerman
  • 3,973
  • 6
  • 38
  • 54

2 Answers2

9

BaseAdapter,ArrayAdapter,SimpleAdapter etc are mostly used if you are getting dynamic data from a remote connection (like a web service or API) and can be modified as your wish.

CursorAdapter is mostly used for local files or database to query the database and the content of it. In your case CursorAdapter seems like the one to go.

Serdar Dogruyol
  • 5,147
  • 3
  • 24
  • 32
4

@serdar explaination is almost right, if you are dealing with any database either your own or device(like contacts, sms etc) CursorAdapter is used, and if you want to make your custom list with Images and Textviews etc, then BaseAdapter is generally used. Any if your dealing with more complex custom listview like sorted contacted list along with seprater like A,B,C... then you have to use EfficientAdapter.

Pawan
  • 1,503
  • 2
  • 19
  • 28
  • What about if you want to show the contacts agenda sort by name? Is it still possible to use the CursorAdapter? – Dayerman Nov 17 '11 at 09:54
  • 1
    Suppose you have to develop an application that wants to show all the contacts saved in your phone, then you'll query contacts database, contacts and sms are saved in the form of SQLite table and by passing parameter while query you can get those contacts in either Ascending or descending order. – Pawan Nov 17 '11 at 10:05