0

I have this object in my Android App source code:

ArrayList<ArrayList<MyObject>> rsp

and i want to store it in a Bundle and use it in OnSaveInstanceState() method in my activity. Then i want to retrieve it from the bundle, too.

Should i use json? Is there another way?

4

2 に答える 2

1

可能であればGson図書館を利用する

 Gson gson = new Gson();
    String output = gson.toJson(rsp); // Create String and pass through bundle

そのリストを文字列から取得します

    //convert from string
String output =  // get that string from bundle
    ArrayList<ArrayList<MyObject>> fromString = gson.fromJson(output,new TypeToken<List<ArrayList<ArrayList<MyObject>>>>(){}.getType());
于 2016-12-28T10:43:23.140 に答える