how to send array of params using volley in android

Use

HashMap<String ,String> params=new HashMap<String, String>(7);
for(int i=1;i<=7;i++)
{
    params.put("params_"+i, arr[i]);
}

in CustomJobjectRequest class because currently you are using String type as value in Map in CustomJobjectRequest class but sending String[] type when create object of CustomJobjectRequest class.

Edit:

To send all values in single parameter to server use JSONObject.Create a json object using all key-value as:

 JSONObject jsonObject=new JSONObject();
 for(int i=1;i<=7;i++)
    {
        arr[i]="questionId_"+i+"_"+"ans_"+i;
        jsonObject.put("params_"+i,arr[i]);
    }
HashMap<String ,String> params=new HashMap<String, String>();
params.put("params",jsonObject.toString());

TO send all values on server side get params and convert to JSON object and iterate to get all values

Leave a Comment