I have 1 realm object and some records inside it. I want to make the object having empty records without fetching it, in a single transaction.
RealmResults<Movie> movies = realm.where(Movie.class).findAll();
movies.deleteAllFromRealm();
Now we have like this but I want something like the following without the first line.
realm.deleteAll(Movies.class);
Is there anything like this? I don't know, may be it will take less time to delete. I am just worried about the time it is taking to delete. In my application I have 10 objects having more than 200,000 records.
The right way of deleting your entire Realm (schema) is to use : Realm realm = Realm. getDefaultInstance(); realm. beginTransaction(); // delete all realm objects realm.
To save data from Realm Studio: Go to File > Save data and select JSON or Local Realm.
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
realm.delete(Movies.class);
}
});
In older Realm versions, it was called Realm.clear(Movies.class);
.
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