Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CursorLoader with startManagingCursor()

I use CursorLoader in my App, to do DB transactions.

My app also has the method calling startManagingCursor(), which is deprecated.

I just want to replace this method calling, so what am I supposed to do ?

like image 413
Ashokchakravarthi Nagarajan Avatar asked Oct 29 '13 07:10

Ashokchakravarthi Nagarajan


People also ask

What does the startManagingCursor () function do?

startManagingCursor does not retain the Cursor's state across configuration changes. Instead, each time the Activity is destroyed due to a configuration change (a simple orientation change, for example), the Cursor is destroyed and must be requeried.

What is CursorLoader?

A CursorLoader is a specialized member of Android's loader framework specifically designed to handle cursors. In a typical implementation, a CursorLoader uses a ContentProvider to run a query against a database, then returns the cursor produced from the ContentProvider back to an activity or fragment.

Is Cursor Loader deprecated?

This class was deprecated in API level 28.

Which method is called to indicate a change in the data of a cursor that has been associated with a CursorLoader?

notifyChange(insertedId, null);


1 Answers

startManagingCursor() is deprecated because it does operations on the main thread which can freeze up the UI and deliver a poor user experience. You should use a CusrorLoader with a LoaderManager instead. Check out this tutorial series from Alex Lockwood for detailed instructions:.

like image 77
Anup Cowkur Avatar answered Oct 01 '22 02:10

Anup Cowkur