I need to find a solution that contains and accesses large fragments of complex global data and methods. It must be accessible from within and from ordinary instance variables of various data classes.
Here is how I did it. I would just like to know if there is something wrong with this or if there is a better / cleaner way.
First I stretch Application
, as recommended many times ...
public class MainDataManager extends Application{ public ... large chunks of data in arrays, lists, sets,....
Now access to it from the inside, as recommended everywhere ...
MainDataManager mainDataManager = (MainDataManager)getApplicationContext();
And since I need to access it from regular instances of data classes ...
public class MyDataClass { public MainDataManager mainDataManager; public String name; public MyDataClass(String namex) { this.name = namex;
Since I have not done this yet, I would like to know if there is anything wrong with this. Memory, efficiency, ...
Thank you very much!
Can I add a small alert? I could just use the MainDataClass
class and access MainDataClass.var or MainDataClass.method().
Are there any disadvantages to REAL?
Is the data in both cases stored on the heap / stack?
source share