I have a static ArrayList defined in my activity, being used by several fragments within it. This ArrayList is sometimes modified.
Is this bad practice? Should I be using bundles/SQLite instead?
I have a static ArrayList defined in my activity, being used by several fragments within it. This ArrayList is sometimes modified.
Is this bad practice? Should I be using bundles/SQLite instead?
Yes static is always bad (you should avoid it whenever possible), because even if you dont have access to the Activity instance you can modify it like this SomeActivitiy.list.removeAll();
for example.
What I would suggest it the use of a DataProvider that contains your data and you just have to inject it in your fragments.
The SQLite option in the other hand should only be used when you have to persist the data, so you don't have to delete after using it.
Consider using public field ArrayList
and your fragments can use or modify it easily.
But, please read this first. Public field or Getter/Setter