android - What's the purpose of startManagingCursor? -
ok, documentation states lets activity manage cursor's lifecycle. don't see point of since when activity destroyed, references newly created cursor should erased , cursor left perish in next garbage collecting cycle. why bother?
you should not rely on cursors being destroyed garbage collector... cursor represents significant amount of resources: of data held cursor, plus connection content provider owns cursor means requiring process kept in memory.
in more recent versions of android, log messages printed if cursor's finalizer runs without being explicitly closed, because important apps close cursors when done them.
managed cursors take care of closing cursor when activity destroyed, more well: deactivated , requeried activities stopped , restarted.
that said, @ point should consider managed cursors deprecated. new loader api lot better, , has many improvements user experience of app -- ensures cursor operations done off main thread (so there not glitches in ui interactions , animations), , can propagate existing cursor data across activity instances when activity restarted due configuration change instead of having reload data.
if need run on older versions of android 3.0, can use v4 support library's implementation of loader applications.
Comments
Post a Comment