Java Code Examples for io.realm.RealmQuery#findAll()
The following examples show how to use
io.realm.RealmQuery#findAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RealmBufferResolver.java From TimberLorry with Apache License 2.0 | 6 votes |
@Override public List<Record> fetch() { List<Record> records = new ArrayList<>(); Realm realm = null; try { realm = Realm.getInstance(realmConfig); RealmQuery<RecordObject> query = realm.where(RecordObject.class); RealmResults<RecordObject> results = query.findAll(); for (RecordObject obj : results) { records.add(new Record(Utils.forName(obj.getClassName()), obj.getBody())); } return records; } finally { if (realm != null) realm.close(); } }
Example 2
Source File: ManagedLiveResults.java From realm-monarchy with Apache License 2.0 | 5 votes |
@Override protected void onActive() { realm = Realm.getInstance(realmConfiguration); RealmQuery<T> realmQuery = query.createQuery(realm); if(asAsync) { realmResults = realmQuery.findAllAsync(); // sort/distinct should be done with new queries, 5.0+ } else { realmResults = realmQuery.findAll(); // sort/distinct should be done with new queries, 5.0+ } realmResults.addChangeListener(realmChangeListener); if(!asAsync) { setValue(new Monarchy.ManagedChangeSet<T>(realmResults, new EmptyChangeSet())); } }
Example 3
Source File: NotesFragment.java From multi-copy with Apache License 2.0 | 5 votes |
private void refreshData(){ Realm realm = Realm.getDefaultInstance(); RealmQuery<NotesModel> notesModelRealmQuery = realm.where(NotesModel.class); RealmResults<NotesModel> query = notesModelRealmQuery.findAll(); notesList.clear(); notesList.addAll(query); notesAdapter.notifyDataSetChanged(); }
Example 4
Source File: RealmMember.java From iGap-Android with GNU Affero General Public License v3.0 | 5 votes |
public static RealmResults<RealmMember> filterMember(long roomId, @Nullable String filter) { Realm realm = Realm.getDefaultInstance(); RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo(RealmRoomFields.ID, roomId).findFirst(); if (realmRoom == null) { return emptyResult(realm); } RealmResults<RealmMember> searchMember = emptyResult(realm); RealmResults<RealmRegisteredInfo> findMember; if (filter != null && filter.length() > 0) { findMember = realm.where(RealmRegisteredInfo.class).contains(RealmRegisteredInfoFields.DISPLAY_NAME, filter, Case.INSENSITIVE).findAll().sort(RealmRegisteredInfoFields.DISPLAY_NAME); } else { findMember = realm.where(RealmRegisteredInfo.class).equalTo(RealmRoomFields.ID, roomId).findAll().sort(RealmRegisteredInfoFields.DISPLAY_NAME); } try { RealmQuery<RealmMember> query; if (realmRoom.getType() == GROUP) { query = realmRoom.getGroupRoom().getMembers().where(); } else { query = realmRoom.getChannelRoom().getMembers().where(); } for (int i = 0; i < findMember.size(); i++) { if (i != 0) { query = query.or(); } query = query.equalTo(RealmMemberFields.PEER_ID, findMember.get(i).getId()); } if (findMember.size() > 0 || (filter == null || filter.length() == 0)) { searchMember = query.findAll(); } } catch (Exception e) { e.printStackTrace(); } return searchMember; }
Example 5
Source File: Expense.java From Expense-Tracker-App with MIT License | 5 votes |
public static RealmResults<Expense> getExpensesList(Date dateFrom, Date dateTo, @IExpensesType Integer type, Category category) { RealmQuery<Expense> realmQuery = RealmManager.getInstance().getRealmInstance() .where(Expense.class); if (dateTo != null) { realmQuery.between("date", dateFrom, dateTo); } else { realmQuery.equalTo("date", dateFrom); } if (category != null) realmQuery.equalTo("category.id", category.getId()); if (type != null) realmQuery.equalTo("type", type); return realmQuery.findAll(); }
Example 6
Source File: ReadDataActivity.java From example with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_read_data); realm = Realm.getInstance(this); RealmQuery<User> query = realm.where(User.class); RealmResults<User> result = query.findAll(); for (User data : result) { Log.d("test", "Name : " + data.getName() + ", age : " + data.getAge()); } }
Example 7
Source File: AlarmDAO.java From sleep-cycle-alarm with GNU General Public License v3.0 | 4 votes |
public List<Alarm> getListOfAlarms() { Realm realm = RealmManager.getRealm(); RealmQuery<Alarm> query = realm.where(Alarm.class); return query.findAll(); }