I wrote a custom CursorLoader
based on the SimpleCursorLoader
source code that comes within the support library. You can search this site for more information about writing a custom one.
Do I REALLY need to use ContentProvider?
-
23-06-2023 - |
Question
If I do need it, I'll have to modify about 15 classes (models and model-manager classes), so I really want to know if I need a ContentProvider
.
Here's where I am:
Similar to Twitter, I'm getting rows of data from a server, and saving it locally in case the user has no Internet connection. But the ideal way is to always get it from the Server.
I am probably not going to use
SimpleCursorAdapter
because the rows of data I get from the server includes URLs, which means I have to create a custom adapter to display images.I need to load data into the
ListViews
asynchronously because I'm having aViewPager
with 3Fragments
that shows the same data (different filters tho), so, since aViewPager
loads 3Fragments
into memory, it means 3 queries are executing (and that's most likely the cause of non-smooth swiping).
So far, the way I synchronize data between the App and the Server is:
Fragment.onStart()
executes anAsyncTask
which returns rows of data formatted asJSON
data- Said
AsycTask.onPostExecute()
updates theList<E>
and callsAdapter.notifyDataSetChanged()
The issue here is that each time I change tabs, the onStart()
is called, ergo the AsyncTask
executes causing the UI not being smooth.
Should I change the way I synchronize data with the Server, or should I use ContentProvider
?
EDIT: as a head up, the reason I'm asking is that startManagingCursor()
method is depracated. It says to use the Loader
framework, but it seems it's only available through ContentProvider
Solution 2
OTHER TIPS
You don't need to develop your own provider if you don't intend to share your data with other applications. However, you do need your own provider to provide custom search suggestions in your own application. You also need your own provider if you want to copy and paste complex data or files from your application to other applications.
from http://developer.android.com/guide/topics/providers/content-providers.html