It is possibly duplicate for Question1 or Question2, but for me its still not clear. They say, try-with-resources supported from 19 api only, but refer to that question its not so.
I have tested by my own with Realm
.
boolean isClosed = RealmManager.isClosed(); //false here
try (Realm realm = RealmManager.getRealm()) {
realm.executeTransaction(r -> r.where(User.class).findAll());
} catch (Exception ex) {
ex.printStackTrace();
}
isClosed = RealmManager.isClosed(); //true here
public static boolean isClosed() {
return realm == null || realm.isClosed();
}
And its works fine on 22 api (real phone) and 16 api (emulator). So will that block work fine on pre 19 api on most phones and where is a truth?
I use Retrolabmda
.
Gradle configuration:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}