我在android中创建数据库并在数据库中添加值。在检索数据时,成功检索数据。当我在for循环中获取数据时,它包含14个值。我该如何分离这些值?
dataBaseHelper db = new dataBaseHelper(this);
List<String> studentInfo = db.getContact(eid);
for(Iterator<String> i = studentInfo.iterator(); i.hasNext(); ) {
String item = i.next();
Toast.makeText(getApplicationContext(),item, Toast.LENGTH_LONG).show();
}
在此代码中,我在项目中有14个值,我想分隔每个值。怎么做?
答案 0 :(得分:3)
for(String student : studentInfo){
Toast.makeText(context,student, Toast.LENGTH_LONG).show();
}
答案 1 :(得分:0)
尝试将它们放入数组
dataBaseHelper db = new dataBaseHelper(this);
List<String> studentInfo = db.getContact(eid);
for(Iterator<String> i = studentInfo.iterator(); i.hasNext(); ) {
String item = i.next();
fields[i] = studentInfo.get(i).getValue();
Toast.makeText(getApplicationContext(),item, Toast.LENGTH_LONG).show();
}