Reputation: 2452
I want to check if my xyz.realm database already exists, any ideas on how tackle this?
Upvotes: 5
Views: 3280
Reputation: 20126
This should work:
RealmConfiguration config = getConfig();
if (new File(config.getPath()).exists()) {
// exists
} else {
// don't exists
}
Upvotes: 9
Reputation: 1335
try this:
String defaultName = Realm.getDefaultInstance().getConfiguration().getRealmFileName();
if("xyz.realm".equals(defaultName)){
//TODO
}else{
//TODO
}
Upvotes: 0