List namevaluepair elements

android, foreach, list

Solution

You should simply iterate over the list to get access to each `NameValuePair`. With the `getName()` and `getValue()` methods you can retrieve the individual parameters of every pair.

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

Problem

I am developing an Android project and I have the following code segments which collects 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 that data list in my AsyncConnection class?

Original source