Skip to content

Instantly share code, notes, and snippets.

@pratamawijaya
Created February 20, 2015 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pratamawijaya/ed94b96ec90ea03aa493 to your computer and use it in GitHub Desktop.
Save pratamawijaya/ed94b96ec90ea03aa493 to your computer and use it in GitHub Desktop.
private void readDataFromDb() {
if (locationModels.size() > 0)
locationModels.clear();
RealmResults<LocationModel> result = realm
.where(LocationModel.class)
.findAll();
// sortiny by id.
// show greater first
result.sort("id", RealmResults.SORT_ORDER_DESCENDING);
for (LocationModel data : result) {
Log.d("tag", "datanya " + data.getId());
locationModels.add(data);
}
// notify adapter
adapterRoute.notifyDataSetChanged();
// update view
updateView();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment