Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing multiple static ArrayLists through a whole Android application
    primarykey
    data
    text
    <p>I am developing my first android Application and hoping to get some tips here.</p> <p>I am getting a <code>JSONObject</code> from an url which then will be parsed in an <code>ArrayList&lt;MyObject&gt;</code>. The list will be used in multiple tabs and be filtered as needed for the tabs. The objects within these list can be modified by the user and the changes should be synchronized with the lists.</p> <p>So, to speed up loading time I have created a class <code>DataHolder</code> as a singleton which contains 7 arraylist, based from the one <code>JSONObject</code> in different sorting order and filter criterion. The objects in these lists are references from the original list. Populating the lists works fine.</p> <p>The lists will be used in different fragments and activities. </p> <p>Now the problem: the second activity contains tabs with fragments. After initializing the fragment... all arraylists in the <code>DataHolder</code> counts 0! I have to save the <code>JSONObject</code> in <code>SharedPreferences</code> and populate it again to get the <code>List</code>. I can't load the url again because it is slowing down the app to much and using <code>SharedPreferences</code> is not an option (I think) because of the need to synchronized the <code>Lists</code>. I have read that using static variables is not the optimal solution, but it seems to be the easiest way :(</p> <p>What can I do to solve this problem? Should I use <code>Parcelable Objects</code> and always pass the <code>Lists</code> around? Or maybe use <code>SQLite</code>? Or are there other approaches?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload