0

i have data stored in sqlite database, now it has to be fetched and display it on UI. To do this i have a cursoradapter.

is this the efficient way to display data?, do we need to use content providers & loaders for this purpose? what are there advantages & disadvantages ?

1 Answer 1

1

I usually dont use cursorAdapter instead i create a class "datasource" that handles all databases interactions: create update delete and read where read returns either a single or list of objects containing the data from the database. From there i use a custom adapter to show the data on a list or a gridview.

This tutorial shows how to make that database interaction class http://www.vogella.com/tutorials/AndroidSQLite/article.html

and this one show how to create a custom adapter for a listview http://www.vogella.com/tutorials/AndroidListView/article.html

Sign up to request clarification or add additional context in comments.

6 Comments

It's just the name of a class i created with methods that access data on the database like: public void create(...) public void update(...) public MyCustomObject read(int id) public List<MyCustomObject> readAll() etc
Ok, thank you. So, if we use these loaders, my operation would be faster?
It depends on how much data you are loading. The good thing about the use of cursorloader is that cursorloader will listen for changes in the cursor and refresh the list if any. With a custom adapter you need to tell the adapter when to refresh the list
No problem, if this answer wass helpfull then please accept it using the checkmark on the left of my answer
Hi, sure, Any sample example you have to create content provider and access data via sqlite loader
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.