Cursor cur = acc.query("details", new String[] { "name"}, null,
null, null, null, null);
cur.moveToFirst();
listContent = new String[cur.getCount()];
for (i = 0; i < cur.getCount(); i++) {
String ss1;
ss1 = cur.getString(0);
listContent[i] = ss1;
cur.moveToNext();
}
cur.close();
答案 0 :(得分:0)
尝试:
Cursor cur = acc.query("details", new String[] { "name"}, null,
null, null, null, null);
listContent = new String[cur.getCount()];
int i=0;
while(cur.moveToNext()) {
listContent[i] =cur.getString(0);
i++;
}
cur.close();
并且在不使用任何索引计数器的情况下使用ArrayList而不是Array的简单方法:
Cursor cur = acc.query("details", new String[] { "name"}, null,
null, null, null, null);
List<String> strArrayList = new ArrayList<String>();
while(cur.moveToNext()) {
strArrayList.add(cur.getString(0));
}
cur.close();