我有一个预先填充的领域数据库。 我在那里有以下对象:
public class RLMFormula extends RealmObject {
@PrimaryKey
private String idHighTech;
private String label;
public String getIdhightech() { return idHighTech; }
public void setIdhightech(String idHighTech) { this.idHighTech = idHighTech; }
}
我想在ArrayList中提取所有idHighTech,暂时我这样做:
public ArrayList<String> getAllFormulaID() {
RealmResults<RLMFormula> rlmFormula = realm.where(RLMFormula.class).findAll();
ArrayList<String> formulaListId = new ArrayList<>();
for (int i = 0; i < rlmFormula.size(); i++) {
formulaListId.add(rlmFormula.get(i).getIdhightech());
}
return formulaListId;
}
是否有更高效,更快的东西?