我试图在android上使用ormlite将整个列值转换为arrayList,这是可能的,直接api? 使用原始结果我接近但不完全:
GenericRawResults<String[]> rawResults =
getHelper().getMyProcessDao().queryRaw(
queryBuild.selectColumns("nid").prepareStatementString());
List<String[]> result = rawResults.getResults();
答案 0 :(得分:3)
槽糕。我不确定这是你想要的。但是,通过使用可以传递给RawRowMapper
DAO方法ORMLite's的dao.queryRaw(String, Rowmapper, String...)来实现您特别要求的一种方法。
以下内容应该有效:
RawRowMapper<Integer> mapper = new RawRowMapper<Integer>() {
public Integer mapRow(String[] columnNames, String[] resultColumns) {
// maybe you should verify that there _is_ only 1 column here
// maybe you should handle the possibility of a bad number and throw
return Integer.parseInt(resultColumns[0]);
}
};
GenericRawResults<Integer> rawResults =
getHelper().getMyProcessDao().queryRaw(
queryBuild.selectColumns("nid").prepareStatementString(), mapper);
List<Integer> list = rawResults.getResults();