Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using JsonArray vs ArrayList as a data set to RecyclerView Adapter

I have used both ArrayList<> and JsonArray as the data sets in the adapter. One of the major difference I found was that the data set changes for the local data in Adapter was not reflected back in the calling class for JsonArray.

I wanted to know using which one is better and is my observation correct.

Also if my data set involves extracting data from a webservice(that gives me Json form data) will my changing it to ArrayList<> be better.

like image 405
Harshit Avatar asked Jul 05 '16 20:07

Harshit


2 Answers

JsonArray implemented by ArrayList under the hood. http://grepcode.com/file/repo1.maven.org/maven2/org.json/json/20080701/org/json/JSONArray.java

So its very similar variants for app performance. Use what you like =)

like image 141
mlevytskiy Avatar answered Sep 21 '22 14:09

mlevytskiy


As far as I know JsonArray isn't much slower than ArrayList. So I believe that you should be ok using JsonArray. We would need to see some code to help out with the problem when using jsons.

like image 45
Carlos Sifuentes Avatar answered Sep 22 '22 14:09

Carlos Sifuentes