I want remove all message object from realm those are equal to userid
RealmQuery<Message> rowQuery = realm.where(Message.class).equalTo(Message.USER_ID, userId); realm.beginTransaction(); //TODO : here I want to remove all messages where userId is equal to "9789273498708475" realm.commitTransaction();
Select a realm and click the Edit button. The Edit Realm wizard displays. Click Next to move to the Realm Objects page where you can click Remove to delete objects from the realm. Click Done.
The right way of deleting your entire Realm (schema) is to use : Realm realm = Realm. getDefaultInstance(); realm. beginTransaction(); // delete all realm objects realm.
To delete all objects from the realm, call Realm. deleteAll() inside of a write transaction. This clears the realm of all object instances but does not affect the realm's schema.
Realm is an open-source database management system that is used to develop mobile applications. And the best part? It can be used for free. The Realm supports Android, iOS, Xamarian, and other Native programming languages.
In 0.88.3 and below you can do:
realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { RealmResults<Message> rows = realm.where(Message.class).equalTo(Message.USER_ID,userId).findAll(); rows.clear(); } });
From 0.89 (next release) this will be deleteAllFromRealm()
instead.
realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { RealmResults<Message> result = realm.where(Message.class).equalTo(Message.USER_ID,userId).findAll(); result.deleteAllFromRealm(); } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With