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

Why Update contacts methods does nothing in android
Failed to add the android platform
Database error using new version on upgrade
how to delete row on listView completely
debug mode on samsung galaxy Android 4.3
Android ViewPager, content between tabs and fragments
Android - Integrating ffmpeg and android-ndk-r9c
How to take a screenshot of contents of an Activity, including PopupWindows and AlertDialogs?
How do I add proper longclick and normal click at the same time to my button?
How to map a rectangle inside a scaled and rotated rectangle into the original bigger and unrotated rectangle
Layout causing App to crash
Android: Null Pointer Exception setContentView [closed]
Chat app - updating last row
MvvmCross - request for clarification regarding app structure
Unknown permission in package for android GCM register
Getting screen coordinates with layout weight property - android

Categories

HOME
google-app-engine
fabricjs
time-complexity
angular-formly
pascal
jelastic
oracle-apex-5
sublimetext
javacc
echo
crystal-lang
categorical-data
github-enterprise
plist
cmdb
naivebayes
nancy
selenium-ide
symbol
html5-appcache
pyramid
sse
apache2.4
springfox
r-mice
php-mysqlidb
strongname
onload
asymptotic-complexity
failover
xbox
record
cognos-bi
deltaspike
git-squash
latitude-longitude
z-notation
bc
demo
plaintext
strftime
magento-2.0.7
carrot2
subnet
android-testing
pdf-conversion
payload
d3-force-directed
jtree
branch-prediction
rocks
meteor-packages
segment-io
windows-azure-queues
tooleap
cfchart
gcloud-ruby
cda
hadoop-partitioning
piracy-prevention
avisynth
coda
apache-commons-daemon
jquery-forms-plugin
document-repository
apache-spark-1.3
pseudo-class
post-commit-hook
machine-instruction
with-statement
winginx
spring-3
facebook-timeline
superscrollorama
cardreader
alice
nokia-s40
uimanageddocument
subgraph
mysql-error-1205
pylucene
twitterizer
qglwidget
isapi-extension
glui
purepdf
interop-domino
application-planning
contentpresenter
change-management

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