Nice :)
I did it slightly differently. I already had a standard top level
Activity all my Activities inherit from so in there i defined:
List<CursorAdapter> managedCursorAdaptors = new
ArrayList<CursorAdapter>();
and added the following methods:
protected void addManagedCursorAdapter(CursorAdapter adapter) {
managedCursorAdaptors.add(adapter);
}
protected void removeManagedCursorAdapter(CursorAdapter adapter) {
managedCursorAdaptors.remove(adapter);
}
protected void closeAllManagedCursorAdapters() {
Cursor cursor = null;
for(CursorAdapter adapter : managedCursorAdaptors) {
cursor = adapter.getCursor();
if(cursor != null) {
cursor.close();
}
}
}
I then in the onDestroy() called the closeAllManagedCursorAdapters.
Within my Activities whenever I created a CursorAdapter I don't keep a
reference to it as such I just call addManagedCursorAdapter(adapter)
and forget about it.
Seems to be working well enough and it's just set and forget.
Steve
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en