rustyventure wrote:
> I'm trying to create a method that will post data to a web form. The
> method will accept two parameters: 1) a url; and 2) a collection of
> keys and values representing fields and values on the form. The
> problem is that the fields and values are arbitrary - the names of the
> fields, even the number of fields are unknown.
>
> My first thought was, "hey, just put the fields in a ContentValues
> variable." So, I'd have something like this:
>
> Code:
> ContentValues myFields = new ContentValues();
> myFields.put("form_field_1", "some value");
> myFields.put("form_field_2", "some other value");
>
> myWebFormMethod(myURL, myFields);
>
>
> However, I don't know how to "loop" through a ContentValues variable
> and parse the "key" and "value." All of the examples I've found so far
> expect that you know the names of the keys in advance (which, with my
> method, I won't).
Why not just use Map<String, String> instead? HTML form keys and values
have to be Strings anyway.
I'm not sure what ContentValues is getting you that a typed Map wouldn't.
--
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 1.9 Available!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---