how to add string into JsonArray

android, json

Solution

Simple:

JSONArray list = new JSONArray();
list.put("Hello");
list.put("Hey");

String jsonString = list.toString()

according to docs it should result in "["Hello", "Hey"]"

Problem

I am trying to add string values in JsonArray and after that create Json String to send it on server. I was searching on google but I couldn't find anything helpful. Could anyone tell me how to this? Thanks ``` JSONArray list = new JSONArray(); list.put("Hello"); list.put("Hey"); ``` After that I want create JSONString

Original source