Convert ArrayList to string and back to ArrayList | Techbirds

1:Download gson-2.2.4.jar and Insert Library inside libs folder
2:Then for ex:- you have a ArrayList like this ArrayList filelist= new ArrayList();

then you can change it to string

String json = new Gson().toJson(filelist);

And if you want to change back to ArrayList then

Type type = (Type) new TypeToken() { }.getType(); filelist= new Gson().fromJson( json (java.lang.reflect.Type) type);

}

536 total views, 2 views today

Share this Onfacebook-6407552twitter-2660219linkedin-5351203google-2678829