2

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.

Anil M
  • 1,297
  • 2
  • 19
  • 42

3 Answers3

2

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

Community
  • 1
  • 1
appsroxcom
  • 2,821
  • 13
  • 17
0

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.

AndroidGecko
  • 14,034
  • 3
  • 35
  • 49
0

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);
Adi
  • 13
  • 4