خرید بک لینک

Vote count: 0

In my Android app, I used Gson object in order to save/load the object's Arraylist in SharedPreferences. Follows are my code using Gson.

public static ArrayList<RequestModal> getModalList(Context ctx) {
    Gson gson = new Gson();
    String json = getSharedPreferences(ctx).getString("ModalList", new Gson().toJson(new ArrayList<>()));
    Type type = new TypeToken<ArrayList<RequestModal>>() {}.getType();
    retu gson.fromJson(json, type);
}

In here "RequestModal" is the simple object include a bit of strings and integers. It works well with the exception of the case "offline". But if inteet is offline, forever works on below code.

Type type = new TypeToken>() {}.getType();

How can I solve it? What is the way implement the feature like this with/without using Gson? Please help me anyone having a good idea. Thank you in advance.

asked 4 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 4 ارديبهشت 1395 ساعت: 0:04

صفحه بندی