This is my scenario:
Activity 1 , Is where I have a list with items.
Activity 1 contains an object of Class A , which deals with getting and returning a cursor of data retrieved by an SQLite database, via a Loader Manager set up, to Activity 1 .
In Activity 1 , Each of these views within the list have buttons. When pressing a button, Class B is executed.
Class B changes a single value within the SQLite database.
In Class B , How can I notify the Loader Manager that the data has changed, for it to refresh the cursor. Remember, The Loader Manager is set up in Class A .
Essentially, If the above didn't make sense, I need to refresh the cursor as the underlying sql data has changed, but I need to do this from a class that has not a direct connection to the loader manager.
You can have both classes have access to each other , say in your onCreate in Activity1
ClassA obj1 = new ClassA(...);
ClassB obj2 = new ClassB(...);
obj2.setClasssA(obj1);
and inside your ClassB code, after you're done with updating the db you can just call a method in classA to update the cursor. something a long the line of :
obj1.onNewData();
I hope that makes sense
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.