android - SQLite and SQLiteCursorLoader Library -
I've used Android's before SQLite
, but I always managed to manually manipulate data Therefore, I have never used class like SimpleCursorAdapter
. I want to use them now, but I need a bit of help in implementing code because it says that I have to use a cursor loader
. I have decided that I am using the SQLiteCursorLoader
library.
Here are the details:
I have a table called students
. SQLite database Additionally, student
model class and < Code> student manager / controller class. Calling StudentManager # getAll ()
returns a cursor
in which all students are included.
We go to piece
Anyway, I have not using ListFragment
for versatility, so far I have the following in onCreate
:
studentCursor = studentManager.getAll (); String [] = new string [] {EventManager.COLUMN_TITLE}; String [] = new string [] {R.id.title}; Cursor adapter = new simple cursor adapter (this, r layout.ro_events, event cuoser, from, to, 0); After that, I have a asyncTask
subclass that will retrieve data from a reciprocal API. @Override Public Zero DoInBackground () {// Code to get an array for students (student student in students) {studentManager.save (student); }}
The question will be, in what episode I will use the SQLiteCursorLoader
and
what will happen to EDIT : The question is more likely to be something like this: I am already implementing my own asyncTask
operation because I am recovering and managing all data from a server, therefore, If I'm already managing data in a secondary thread, thanks to doInBackground
, what Uje should still SQLiteCursorLoader
any operation?
Therefore, if I already thank you for managing data in a secondary thread Do I still need the SQLiteCursorLoader for any operation?
Probably not to load the data data of an loader
asynchronously if you are doing yourself, then a loader
Either way more will not make asynchronous: -)
Just remember that if you change your data, you will see a new asyncTask
To run, your UI will need to be updated so that the changed data can be reflected, like fresh cursor
. A Cursor Loader
does this automatically; A SQLiteCursorLoader
does "automatically" if you run the database operation through the self loader.
Comments
Post a Comment