【发布时间】:2014-11-11 20:39:02
【问题描述】:
我有一个名为 Collections 的字符串数组。
String[] Collections;
我的数据库表中保存了整数值。我想从名为 specific_collections 的数据库列中获取整数值。
并将其设置为整数数组 SpecificCollections。
所以,我想这样设置:
String[] Collections = 0;
Integer[] SpecificCollections = getColumnValuesFromSpecificCollectionsColumn();
在将它们设置为整数数组后,我想解析整数数组并将每个 int 值保存到我的字符串数组中,该数组形式如下:
Collections = new String[]{Collection.SpecificCollections.fromInt(SpecificCollections[i]).getString()};
Specific Collections 是来自 db 的整数数组。
编辑:这是我到目前为止所拥有的,但它只是用一个 int 填充列表?
ArrayList<Integer> regionList= new ArrayList<Integer>();
Cursor cursorTwo = sqLiteDatabase.rawQuery("SELECT DISTINCT region FROM collection", null);
if (cursorTwo != null && cursorTwo.getCount() != 0) {
cursorTwo.moveToFirst();
while (!cursorTwo.isAfterLast()) {
regionList.add(cursorTwo.getInt(0));
cursorTwo.moveToNext();
}
}
for (Integer inte : regionList){
regions = new String[]{Collection.Regions.fromInt(inte).getString()};
}
下面是遍历数组列表并在 fromInt() 方法中传递不同整数的正确方法吗?
【问题讨论】: