我想在数据库中存储一个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);
答案 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++;
}
}