You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Found a solution to my problem. Ended up storing the hashmap as a JSON string and then doing the Type conversion myself.
CacheUtils.writeFile(CACHE_NAME, new Gson().toJson(buses));
//.......
String busesStr = CacheUtils.readFile(CACHE_NAME);
Type type = new TypeToken<HashMap<String, Bus>>(){}.getType();
HashMap<String, Bus> buses = new Gson().fromJson(busesStr, type);
I'm getting a
com.google.gson.internal.LinkedTreeMap cannot be cast to <CustomClass>
error when reading a HashMap from cache.Writing to file:
Reading from file:
The text was updated successfully, but these errors were encountered: