I have three buttons sending different variables to an activity:
Intent i = new Intent(getApplicationContext(),PhotosActivity.class);
i.putExtra("DISPLAY_ID", theVenue.displayId);
i.putExtra("ID", theVenue.id);
startActivityForResult(i, 0);
This worked great when in the PhotosActivity I loaded in the data every single time the activity was accessed. However, to make things more efficient, I implemented static variables to store the data and only load once.
private static List<SingleEvent> cachedObject;
The problem is that it stores the data for only the first button clicked. It is apparent to me that I’m not using three instances of PhotosActivity, but only one.
How can I create three separate instances of PhotosActivity and add them as separate activities?
The easiest way to do this is changing cache structure to
HashMap<Integer, List<SingleEvent>>where firs param is yourtheVenue.id. Using map you can store all cache without creating lots of activities.