I want to send particular data from database and parse into jsonarray and send it to server. I am able to send dummy data directly to server .Can you tell me the way to send data (parsed jsondata ) into server.?
Asked
Active
Viewed 72 times
-3
-
1I want to `what you tried so far` ? show – IntelliJ Amiya May 22 '17 at 11:31
-
In the same way as dummy data but you need to get this data from SQL .... what had you tried so far? Where is the problem? – Selvin May 22 '17 at 11:32
-
how do you send `"dummy data"`? – pskink May 22 '17 at 11:34
-
if u able to get data from Sqlite then it is very simple. ! do let me know where do u stuck. – Mohit Kacha May 22 '17 at 11:36
2 Answers
0
For your approach you should firstly create a array list with all your necessary data send to server. You can parse into json using Jakeson see Example here. Resultant will be your data.

Paolo Forgia
- 6,572
- 8
- 46
- 58

laxmikant
- 71
- 9
0
Firstly you have to put all your data in the arrayList then use this code
private String arrayToJson(ArrayList<HashMap<String, String>> arrayList) {
//Coverting Arraylist to JsonArray
List<JSONObject> jsonList = new ArrayList<JSONObject>();
for (HashMap<String, String> data : arrayList) {
JSONObject jsonObject = new JSONObject(data);
jsonList.add(jsonObject);
}
JSONArray json_array= new JSONArray(jsonList);
String json_string= json_array.toString();
}
then you can send this to server. And decode this json_string and retrive your data

Sho_arg
- 383
- 3
- 13