android-loadermanager

What is the appropriate replacement of deprecated getSupportLoaderManager()?

给你一囗甜甜゛ 提交于 2020-02-26 06:27:26
问题 I came to know that getSupportLoaderManager is deprecated. But I want to call: getSupportLoaderManager().initLoader(0, null, mRecipeLoaderManager); What should be an alternative to that call? Or can I still use getSupportLoaderManager without worrying? 回答1: As stated here: Loaders "Loaders have been deprecated as of Android P (API 28). The recommended option for dealing with loading data while handling the Activity and Fragment lifecycles is to use a combination of ViewModels and LiveData."

Android sqlite with multi thread

走远了吗. 提交于 2020-01-14 14:12:03
问题 I am writing a android application using sqlite . There are many activities and one service. I use the DB from more than one thread. It works perfectly in Android 2.X , but once I run it in Android 3.X it always throws this error and Force Close : 05-04 22:17:04.815: I/SqliteDatabaseCpp(8774): sqlite returned: error code = 5, msg = database is locked, db=/data/data/xxx/databases/im 05-04 22:17:04.815: E/SqliteDatabaseCpp(8774): sqlite3_open_v2("/data/data/xxx/databases/im", &handle, 6, NULL)

Android sqlite with multi thread

懵懂的女人 提交于 2020-01-14 14:07:51
问题 I am writing a android application using sqlite . There are many activities and one service. I use the DB from more than one thread. It works perfectly in Android 2.X , but once I run it in Android 3.X it always throws this error and Force Close : 05-04 22:17:04.815: I/SqliteDatabaseCpp(8774): sqlite returned: error code = 5, msg = database is locked, db=/data/data/xxx/databases/im 05-04 22:17:04.815: E/SqliteDatabaseCpp(8774): sqlite3_open_v2("/data/data/xxx/databases/im", &handle, 6, NULL)

A few questions about SQLite database cursors in Android

时光总嘲笑我的痴心妄想 提交于 2020-01-09 19:35:50
问题 To implement database access in my application I followed Lars Vogel tutorial, but I'm very confused about a couple of things... 1) Every time a call is made to fetchTodo a new cursor will be created and returned. Leaving the previous cursor for the garbage collector. So, if I don't use startManagingCursor or even the CursorLoader for that matter, should I call a .close() on the cursor when I'm done with it ? Outside of fetchTodo scope of course, example: Cursor cursor = mNotesAdapter

A few questions about SQLite database cursors in Android

安稳与你 提交于 2020-01-09 19:35:30
问题 To implement database access in my application I followed Lars Vogel tutorial, but I'm very confused about a couple of things... 1) Every time a call is made to fetchTodo a new cursor will be created and returned. Leaving the previous cursor for the garbage collector. So, if I don't use startManagingCursor or even the CursorLoader for that matter, should I call a .close() on the cursor when I'm done with it ? Outside of fetchTodo scope of course, example: Cursor cursor = mNotesAdapter

Android SimpleCursorAdapter vs. LoaderManager/CursorLoader

烂漫一生 提交于 2020-01-05 07:37:30
问题 How can I go about extending SimpleCursorAdapter to allow for the following: 2 fragments, one menu one detail. Menu ListFragment is a list of tables, detail ListFragment shows the result of a query against these tables. The detail ListFragment gets passed a table name from the selection in the menu ListFragment. In onActivityCreated inside the detail ListFragment, all records are selected into a cursor. This cursor is passed into a SimpleCursorAdapter. This SimpleCursorAdapter is then set as

Getting “Called doStart when already started” from LoaderManager. Why?

筅森魡賤 提交于 2020-01-01 09:16:06
问题 My code has an Activity, that has a FragmentPagerAdapter that creates 'n' fragments as necessary. Activity has a loader, and each fragment has its own loader. All loaders have unique ID. (Activity's loader in fact determines the number of Pages in the adapter) I keep getting this warning here and there and can't put my finger on what's causing it. It doesn't seem to be critical, also looking at the LoaderManger's code throwing this warning, but still - warnings are usually signs for bugs..

Global Loader (LoaderManager) for reuse in multiple Activities / Fragments

余生颓废 提交于 2020-01-01 07:42:04
问题 What I would like to achieve: I have two different fragments. I would like them both to show the same data in two forms (in a list and on a map). I would like them to share one Loader ( AsyncTaskLoader in particular). Everything works fine, but the Loader isn't re-used. Another one is created and the data is loaded twice. What I do: In the Fragment s I use LoaderManager lm = getActivity().getSupportLoaderManager(); In both of them I implement LoaderCallbacks<ArrayList<Item>> and the required

SimpleCursorAdapter's old constructor deprecated.. really?

柔情痞子 提交于 2019-12-31 22:24:12
问题 Here it says that SimpleCursorAdapter 's API level 1 constructor is deprecated and the use of LoaderManager and CursorLoader is recommended. But delving into the LoaderManager and CursorLoader 's use I found this example where inside an inner class that extends a ListFragment (an extension of Fragment itself I suppose) we create a CursorLoader . Everything seems ok, except for the fact that CursorLoader takes a Uri as an argument. So this implies that I need to create a ContentProvider to get

Using a ListFragment with a SimpleCursorAdapter with the Holder Pattern

∥☆過路亽.° 提交于 2019-12-24 01:19:32
问题 I am implementing a ListFragment from a ViewPager and using a ListAdapter extending SimpleCursorAdapter and trying to keep the same Holder Pattern I was using before the conversion to using a LoaderManager with custom cursor and the CommonsWare.loaderex JAR. Everything seems to be fitting together well except I placed the LoaderManager on the ListFragment and not in the FragmentActivity hosting the ViewPager . Mostly because I was not sure about the required call backs to load / refresh the