Reputation: 1307
Is there any alternative to send request parameters through android other than NameValuePair
. I'm trying to send arraylist as request parameter, but NameValuePair
accepts only string value.
Upvotes: 2
Views: 2894
Reputation: 13
Store arraylist in to a string and then send it..
ArrayList<String> contactlist=new ArrayList<String>();
contactlist.add("Android");
contactlist.add("tarnaka");
contactlist.add("uppal");
contactlist.add("Prasad");
String[] contact=new String[contactlist.size()];
contact=contactlist.toArray(contact);
Upvotes: 0
Reputation: 14174
read about JSONObject, JSONArray .. you can convert it to string with toString method and then bring it back to JSONObject, JSONArray passing this String constructor if you receive it from server.
Generally its a standard way of passing complex structures.
Upvotes: 0
Reputation: 2821
You may consider sending the ArrayList as JSONArray.
Check this SO post.
convert ArrayList<MyCustomClass> to JSONArray
Convert normal Java Array or ArrayList to Json Array in android
Upvotes: 2