Questions tagged [android-loadermanager]

An abstract class associated with an Activity or Fragment for managing one or more Loader instances. This helps an application manage longer-running operations in conjunction with the Activity or Fragment lifecycle; the most common use of this is with a CursorLoader, however applications are free to write their own loaders for loading other types of data.

Interface associated with an Activity or Fragment for managing one or more Loader instances associated with it. This helps an application manage longer-running operations in conjunction with the Activity or Fragment lifecycle; the most common use of this is with a CursorLoader, however applications are free to write their own loaders for loading other types of data.

While the LoaderManager API was introduced in HONEYCOMB, a version of the API at is also available for use on older platforms through FragmentActivity.

There is only one LoaderManager per activity or fragment. But a LoaderManager can have multiple loaders.

Useful links

397 questions
129
votes
4 answers

AsyncTaskLoader vs AsyncTask

Since Honeycomb and the v4 Compatibility Library it is possible to use AsyncTaskLoader. From what I understand, the AsyncTaskLoader can survive through config changes like screen flips. Is it recommended to use AsyncTaskLoader instead of AsyncTask?…
OKA
  • 1,423
  • 2
  • 11
  • 7
129
votes
6 answers

Difference between initLoader and restartLoader in LoaderManager

I'm completely lost regarding the differences between the initLoader and the restartLoader functions of the LoaderManager: They both have the same signature. restartLoader also creates a loader, if it does not exist ("Starts a new or restarts an…
theomega
  • 29,902
  • 21
  • 83
  • 125
116
votes
3 answers

LoaderManager with multiple loaders: how to get the right cursorloader

To me it's not clear how to get the right cursor if you have multiple Loaders. Lets say you define two different Loader with: getLoaderManager().initLoader(0,null,this); getLoaderManager().initLoader(1,null,this); then in onCreateLoader() you do…
Kay Gladen
  • 1,730
  • 2
  • 14
  • 13
107
votes
5 answers

CursorLoader usage without ContentProvider

Android SDK documentation says that startManagingCursor() method is depracated: This method is deprecated. Use the new CursorLoader class with LoaderManager instead; this is also available on older platforms through the Android compatibility…
79
votes
2 answers

Using Singleton design pattern for SQLiteDatabase

I'm rather newbie on Android, and I'm working on a simple application to get some basic experience. My app is pretty simple and consists among other things of a broadcast receiver and some activities. Both components make use of a single database,…
Dan
  • 1,446
  • 2
  • 14
  • 25
65
votes
19 answers

getLoaderManager().initLoader() doesn't accept 'this' as argument though the class (ListFragment) implements LoaderManager.LoaderCallbacks

I'm having trouble following a guide on using SQLite in Android. I'm using a ListFragment instead of a ListActivity(as in the example), so I have the ListFragment implement LoaderManager.LoaderCallbacks instead. Then, in the fillData()…
vurp0
  • 1,025
  • 2
  • 9
  • 13
54
votes
2 answers

android - CursorLoader & SQLite without Content Provider

I know this has been discussed yet I wanted to ask about the current state of the matter. Do i have to create a ContentProvider to use CursorLoader in connection with a sqlite database? I found CursorLoader usage without ContentProvider Looks…
dorjeduck
  • 7,006
  • 10
  • 45
  • 62
49
votes
3 answers

CursorLoader not updating after data change

I have created a small application, trying to understand the functionality of the LoaderManager and CursorLoader-classes. I have implemented LoaderCallbacks on my FragmentActivity-class and everything works fine, except the fact that when I…
40
votes
5 answers

Is it OK to have one instance of SQLiteOpenHelper shared by all Activities in an Android application?

Would it be OK to have a single instance of SQLiteOpenHelper as a member of a subclassed Application, and have all Activities that need an instance of SQLiteDatabase get it from the one helper?
Julian A.
  • 9,850
  • 12
  • 57
  • 98
40
votes
2 answers

Can you use a LoaderManager from a Service?

I have a data loading system set up using a custom Loader and Cursor that is working great from Activities and Fragments but there is no LoaderManager (that I can find) in Service. Does anyone know why LoaderManager was excluded from Service? If…
36
votes
3 answers

Loaders in Android Honeycomb

I'm trying to figure out how to use Loaders in Android 3.0 but can't seem to get it to work. The docs only describe using CursorLoader but I'm using AsyncTaskLoader. From the docs it seems that you should only need to implement…
31
votes
1 answer

Android 3.0 - what are the advantages of using LoaderManager instances exactly?

With 3.0 we got the fancy LoaderManager, which handles data loading using the AsyncTaskLoader, the CursorLoader, and other custom Loader instances. But reading through the docs for these I just couldn't get the point: how are these better than just…
29
votes
5 answers

Data out of sync between a custom CursorLoader and a CursorAdapter backing a ListView

Background: I have a custom CursorLoader that works directly with SQLite Database instead of using a ContentProvider. This loader works with a ListFragment backed by a CursorAdapter. So far so good. To simplify things, lets assume there is a Delete…
29
votes
2 answers

Android: CursorLoader, LoaderManager, SQLite

Trying to update my old app in which some methods are deprecated. I found out that if I want to work with ListView that shows data from db, I should use LoaderManager + CursorLoader. CursorLoader works with content providers. So for every table in…
Jim
  • 7,796
  • 16
  • 63
  • 118
28
votes
4 answers

Initializing a Loader in an Activity

I am currently trying to learn how to use Loaders and am having trouble starting a Loader in my activity. import android.support.v4.app.LoaderManager; import android.support.v4.content.Loader; public class ASwitchActivity extends Activity…
d.mc2
  • 1,107
  • 3
  • 16
  • 29
1
2 3
26 27