Hi im trying to truncateall tables in android when a user logs out. im using realms default path only.
realm = Realm.getInstance(getApplicationContext());
public void clearDB() {
Realm.deleteRealmFile(instance);
}
Use realm. delete(Foo. class) instead as clear() is deprecated.
The right way of deleting your entire Realm (schema) is to use : Realm realm = Realm. getDefaultInstance(); realm. beginTransaction(); // delete all realm objects realm.
Yes definitely you can use Realm for free to save unlimited data locally. Realm is only charging for cloud storage .
Update
Use realm.delete(Foo.class)
instead as clear()
is deprecated. From 0.91.0
all @Deprecated
methods will be removed.
Christian from Realm here. That approach will work as long as you have closed all open Realm instances. Another approach is clearing the tables you want like this:
realm = Realm.getInstance(getApplicationContext());
public void clearDB() {
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
realm.clear(Foo.class);
realm.clear(Bar.class);
}
});
}
You can read more here: http://realm.io/docs/java/0.77.0/api/io/realm/Realm.html#clear(java.lang.Class)
use realm.delete(Myclass.class);
realm = Realm.getDefaultInstance();
realm.beginTransaction();
realm.delete(SuggestedAppDto.class);
realm.delete(WifiSpotsDto.class);
realm.commitTransaction();
realm.close();
this worked for me.
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