Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List namevaluepair elements

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?

like image 845
sisko Avatar asked Jun 02 '12 20:06

sisko


1 Answers

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();
}
like image 170
MH. Avatar answered Sep 28 '22 07:09

MH.