如何转换ArrayList <hashmap <string,string =“”>&gt;到StringArray?

时间:2015-06-08 09:30:05

标签: android

我想在数据库中存储一个String数组,但我从另一个活动获得的值为ArrayList<Hashmap<String, String>>。我应该如何将此ArrayList转换为String数组?

代码:

HashMap <String, String> h1 = new HashMap <String, String> ();
h1.put("member_id", member_id);
h1.put("categoryname", category_name);
h1.put("routinetype", routine_type);
h1.put("targettype", target_type);
h1.put("days", countOfDays);
h1.put("point", points);
h1.put("daystring", listOfDayString);
h1.put("create_date", strDate);
arrayList1.add(h1);

1 个答案:

答案 0 :(得分:0)

只需使用:

String[] strArray = new String[urArrayList.size()];
strArray = urArrayList.toArray(strArray);

编辑:

然后你可以简单地使用它:

int i = 0;
String strArr[] = new String[urArrayList.size()];
for (HashMap<String, String> hashMap : urArrayList) {
 for (String value : hashMap.values()) {
    strArr[i] = value ;
    i++;

 }
}