android


Get all realm Objects in Android


Is there a way to get all existing Objects in Realm.
There are around 1000 Objects(Tables), each Object has 10000+ items.
For every 1 hour some items get's expired.
// Class[] clazzez = realm.getSchema();
Class[] clazzez = new Class[] { // How to get all classes dynamically?
Demo.class, AnotherDemo.class, SomeOtherDemo.class
};
// To delete expired items
for(Class clazz: clazzez) {
realm.where(clazz)
.greaterThan("maxAge", new Date().getTime())
.findAll()
.deleteAllFromRealm();
}
It's very difficult to keep track of all classes. How to get all classes dynamically?
With realmConfiguration.getRealmObjectClasses(); (0.88.0+).
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()...build();
// ...
Set<Class<? extends RealmModel>> schemaClasses = realmConfiguration.getRealmObjectClasses(); // <---
// To delete expired items
for(Class clazz: schemaClasses) {
realm.where(clazz)
.greaterThan("maxAge", new Date().getTime()) // <-- assumes existence of "maxAge" field
.findAll()
.deleteAllFromRealm();
}

Related Links

Android connect to bluetooth device with click button on bluetooth device
Resources.getIdentifier() Generates Resource IDs
How to keep android device's layout responsive
Does anyone know if there is a limitation on the size of the file BitmapFactory.decodeFile can decode?
Dagger and AndroidAnnotations - how to inject #Pref, #Bean, etc?
Android Webview Disable Form input Zoom
Parallexing background upside down and not fullscreen
Android application not full-screening
How to create dynamic url with multiple parameters?
Android & Google Play publishing for customers
Android, prevent to kill service/thread
Oncreate call multiple times due to fragment transaction
How to launch the app from the start when started from home button
scene2d button scaling with libgdx
create image gallery in android with thumbnail navigation
Format text in listview (filling from DB)

Categories

HOME
uml
xml
c99
ggplot2
fpga
ns-3
replace
square
iis-6
google-admin-sdk
pkcs#11
project
pega
tput
intercom
plink
eip
flatpak
selectize.js
libusb
red5
sar
google-maps-autocomplete
springfox
highstock
rpgle
tpm
paperjs
errbot
user-defined-functions
bioinformatics
google-cast
volatile
dst
record
sql-server-2000
rselenium
baidu-map
swagger-php
xdocreport
release
doc
android-exoplayer
chai-as-promised
netbeans6.8
modelsim
spring-data-couchbase
jqchart
google-photos
bootstrap-tags-input
javafx-css
juice-ui
meteor-packages
seek
watch-os-2
bizagi
boost-serialization
kiosk
pushbots
exim4
jaunt-api
highland.js
jnlua
iokit
pypiserver
android-launcher
lasso
rrule
gamekit
procedural-programming
boost-program-options
pseudo-class
ss7
reflector
ray
dct
memset
xmltodict
eclipse-kepler
light
scrypt
cmmi
octal
android-sdk-2.3
veracity
garbage
gobject-introspection
procedures
landscape-portrait
http-daemon
non-clustered-index
eclipse-marketplace
addchild
pagemethods
duplex
lxr
application-planning
int64
firefox-3
xslcompiledtransform
online-storage

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App