Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.Map.Entry; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import android.content.ContentValues; public class Main { public static List<NameValuePair> convertParams(ContentValues params) { if (params == null || params.size() == 0) return null; List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); Set<Entry<String, Object>> setEntry = params.valueSet(); BasicNameValuePair bnvp = null; for (Entry<String, Object> entry : setEntry) { bnvp = new BasicNameValuePair(entry.getKey(), entry.getValue().toString()); nameValuePairs.add(bnvp); } return nameValuePairs; } public static List<NameValuePair> convertParams(Map<String, String> params) { if (params == null || params.size() == 0) return null; List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); Set<Entry<String, String>> setEntry = params.entrySet(); BasicNameValuePair bnvp = null; for (Entry<String, String> entry : setEntry) { bnvp = new BasicNameValuePair(entry.getKey(), entry.getValue()); nameValuePairs.add(bnvp); } return nameValuePairs; } }