我是 Realm 的初学者。
我有一个包含 3 列的表格,分别命名为 Id、Name、Email、Address。 为了获取 Name 列的数据,我们使用 SQLite 的查询,例如 'SELECT Name from table_name'。
如果我们在 Android 中使用 Realm,那么我们必须使用哪种方法来获取只有一列的数据?
我在 Google 和文档上进行了大量搜索,但无济于事。 谁能帮帮我?
更新:
我尝试过的:
RealmResults<User> results = query.findAll();
ArrayList<String> name = new Arraylist();
for(i=0; i<results.size; i++){
name.add(result.get(i).getName();
}
我的问题:
results.size() > 10k. So I want to avoid 10k iteration
for(i=0; i<results.size; i++){
}
最佳答案
看queries文档部分:
All fetches (including queries) are lazy in Realm, and the data is never copied.
这意味着,当您调用 getMyProperty()
方法时,将获取特定列(属性)的数据。不是在 RealmQuery
对象的 finadAll()
方法调用之后
关于android - 从 Realm 数据库中获取单个列(Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42640753/