I have two methods which read the same data from database, the first returns Cursor and the second returns List of objects.Now I show my items in activity using SimpleCursorAdapter and the first method, byt I can also use the second method and appropriate adapter.
Which of these two ways is beter to use and in the second way which adapter I should use?
P.S sorry for poor english
Definitely go with
SimpleCursorAdapter. If possible, always useCursorif your data comes fromdatabase, you save memory by not creatingListof objects. Creating objects in Java is expensive with regards to time and memory consumption and you have to bear in mind you are on mobile platform with limited resources. If you are usingListof objects for yourListViewthan use custom adapter extending fromArrayAdapter.It’s not always straightforward to use
Cursoralthough your data comes fromdatabase. Let’s say you store places in thedatabasedefined by its name and location and you want to display them in aListViewsorted by distance from current location. It makes it difficult to execute a query which returns sorted results unless you don’t store relative distance in additional column. But you can getCursorconvert it toListof objects and sort this collection before sending it to yourListView.