Namevaluepair elements

I am developing an Android project, and I have the following code segments that collect information into an “array”:

//setup array containing submitted form data
ArrayList<NameValuePair> data = new ArrayList<NameValuePair>();
data.add( new BasicNameValuePair("name", formName.getText().toString()) );
data.add( new BasicNameValuePair("test", "testing!") );


//send form data to CakeConnection
AsyncConnection connection = new AsyncConnection();
connection.execute(data);

My problem is how to read the individual members of this data list in my AsyncConnection class?

+5
source share
1 answer

You just have to iterate over the list to gain access to everyone NameValuePair. Using the methods getName()and getValue()you can get the individual parameters of each pair.

for (NameValuePair nvp : data) {
    String name = nvp.getName();
    String value = nvp.getValue();
}
+16
source

All Articles