public static String convertSetListToString(ArrayList<GCSavedSet> setArrayList) { String setListString = ""; for (GCSavedSet set : setArrayList) { setListString += set.getId(); setListString += ","; } return setListString; }
public static ArrayList<GCSavedSet> convertStringToSetList( Context context, String setListString) { ArrayList<GCSavedSet> setArrayList = new ArrayList<>(); String[] stringParts = setListString.split(","); ArrayList<GCSavedSet> allSavedSets = GCDatabaseHelper.getInstance(context).SAVED_SET_DATABASE.getAllData(); for (String part : stringParts) { for (GCSavedSet set : allSavedSets) { if (set.getId() == Integer.parseInt(part)) { setArrayList.add(set); break; } } } return setArrayList; }