I knew this question has been asked before. Due to my novice skill in java and android. I can\'t resolve this issue for more than a week.
One of my friend and i dev
In my case error occurred while fetching a list of objects from shared preferences. The error was solved by adding TypeToken as shown below:
public static GenericClass getListOfObjectsFromSharedPref(Context context,String preferenceFileName, String preferenceKey ){
SharedPreferences sharedPreferences =
context.getSharedPreferences(preferenceFileName, 0);
Type type = new TypeToken>() {}.getType();
String json = sharedPreferences.getString(preferenceKey, "");
final Gson gson = new Gson();
return gson.fromJson(json, type);
}
....