Android eclipse startManagingCursor Deprecated but want to support older API versions?

0

Issue

I am trying to understand something, and I am sure it is very basic to some people.

I read everywhere that the startManagingCursor method is deprecated and you should use the CursorLoader class. But does that mean that you should use the CursorLoader class even for apps that support API levels < 11? Or is it saying that if you intend to only support Honeycomb and up, THEN use cursorLoader?

I don’t appear to be able to import the cursor loader class with api 4, so i assume that using CursorLoader doesn’t apply until Android 3.0+, but can someone verify for me please?

Thanks

Solution

I read everywhere that the startManagingCursor method is deprecated and you should use the CursorLoader class.

If you are willing to inherit from FragmentActivity, you can use the Loader framework implementation in the Android Support package, going all the way back to Android 1.6.

That being said, “deprecated” in Android usually means “we will continue to support this, but we think there are better solutions”. You can certainly use startManagingCursor() on API Level 11+. However, the problems with managed cursors (notably that they requery() on an activity restart on the main application thread) are still there, on older and newer Android versions.

But does that mean that you should use the CursorLoader class even for apps that support API levels < 11?

You certainly can, and, all else being equal, you probably should. However, all else is rarely equal, and the FragmentActivity requirement may be a problem for you.

If you are developing a new application, today, you should be thinking about fragments from the outset, in which case you would be using FragmentActivity anyway, and therefore using Loader should not be a problem.

I don’t appear to be able to import the cursor loader class with api 4

The Android Support package implementation of Loader works on API Level 4 and above.

Answered By – CommonsWare

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More