Come cancellare il database di realm predefinito in Android? Ho provato a seguire il codice ma non posso risolvere il metodo deleteRealmFile.Database predefinito di Realm Android clear
Metodo 1:
try {
Realm.deleteRealmFile(context);
//Realm file has been deleted.
} catch (Exception ex){
ex.printStackTrace();
//No Realm file to remove.
}
ho cercato di eliminare utilizzando la configurazione.
Metodo 2:
try {
Realm.deleteRealm(realm.getConfiguration());
//Realm file has been deleted.
} catch (Exception ex){
ex.printStackTrace();
//No Realm file to remove.
}
ma è dà l'errore:
java.lang.IllegalStateException: It's not allowed to delete the file associated with an open Realm. Remember to close() all the instances of the Realm before deleting its file.
questo non funziona non funziona, gettando java.lang.IllegalStateException: Non è consentito di eliminare il file associato ad un Reame aperta. Ricorda di chiudere() tutte le istanze del Realm prima di eliminare il suo file. – shekar