Hi people,
I think I need some help here.
I did some search in the group and found this few 
topics<https://groups.google.com/forum/#%21searchin/android-developers/startManagingCursor$20deprecated>about
 my questions, so sorry if I am being silly.

First, When should I close my Cursors? I always close them in the onPause 
method of an Activity (with the code bellow), and due a HoneyComb issue 
before "open" the Cursor I check if it's not null and "opened" to avoid the 
error described 
here<https://groups.google.com/forum/#%21searchin/android-developers/startManagingCursor$20deprecated/android-developers/BlgTO-yQHX4/whQZ345ITb0J>
:

protected void onResume () {
   if(cursor != null && !cursor.isClosed()){
      stopManagingCursor(cursor);
      cursor.close();
   }
   cursor = getCursorFromMySQLiteDataBase();
   startManagingCursor(cursor);

   //use cursor to fill a ListView ou Spinner
}

protected void onPause () {

  if(cursor != null && !cursor.isClosed()){
      stopManagingCursor(cursor);
       cursor.close();
     }
}

}

Stop the cursor in onPause method seems to be a good thing because, when I 
call another Activity from this, the father Activity is paused, right? I 
also because when I close the app, onPause is also performed, right again?

I know the startManagingCursor and StopManagingCursor is deprecated (this 
page<http://developer.android.com/reference/android/app/Activity.html#startManagingCursor%28android.database.Cursor%29>says
 it):

"Use the new 
CursorLoader<http://developer.android.com/reference/android/content/CursorLoader.html>class
 with 
LoaderManager<http://developer.android.com/reference/android/app/LoaderManager.html>instead;
 this is also available on older platforms through the Android 
compatibility package. "

But CursorLoader and LoaderManager works just with ContentProviders, right? 
That I am doing (above code) it's a bad thing? I need to get a away to 
change all my databases methods to use only ContentProviders? 

The documentation is not very clear about it. 
Here<http://developer.android.com/reference/android/content/ContentProvider.html>say:

"If you don't need to share data amongst multiple applications you can use 
a database directly via 
SQLiteDatabase<http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html>.
 
"

but how to keep managing my Cursors from SQLiteDatabase without use 
[start,stop]ManagingCursor (since it's deprecated and probably soon it will 
not be there)?

Well, I made a lot of questions in this topic, I don't want to mess around, 
I am just lost in those questions.

Sorry again if I am being not clear enough about, I tried to, English is 
not my first lang.
Thanks in advance.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to