Closed VilauGC closed 7 years ago
Use new RealmConfiguration.Builder()
i have the same issue and by using only new RealmConfiguration.Builder() it stills not working
You also need to call Realm.init(Context)
beforehand at some point
Hello! this is how i solved the problem :) I've created a new class that extends the Application because you need to pass an argument to the Realm.init() that is a context
public class AppBucketDrops extends Application { @Override public void onCreate() { super.onCreate(); Realm.init(this);
and i went to the manifest file and tag it another line :
<application
//this is the line i'm talking about android:name=".AppBucketDrops"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ActivityMain">
and after all of this i went to the ActivityMain class inside onCreate(), and like this you wont need a configuration anymore.
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mRealm = Realm.getDefaultInstance();
hope this was helpfull.
Best regards,
Vilau George
2017-01-27 20:05 GMT+02:00 taha786 notifications@github.com:
i have the same issue and by using only new RealmConfiguration.Builder() it stills not working
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/realm/realm-java/issues/4010#issuecomment-275731879, or mute the thread https://github.com/notifications/unsubscribe-auth/AT4b3UINNe-l_mVwHa0aq1QuIxUNWYQjks5rWjHkgaJpZM4Lfgu2 .
I think you also need to call Realm.setDefaultConfiguration()
, but yes
Well...they said that you don't need that anymore. So i haven't put it anywhere, and it still worked.
2017-01-27 20:55 GMT+02:00 Gabor Varadi notifications@github.com:
I think you also need to call Realm.setDefaultConfiguration(), but yes
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/realm/realm-java/issues/4010#issuecomment-275744305, or mute the thread https://github.com/notifications/unsubscribe-auth/AT4b3XC3FZLs-38MlGuTIU1V9VvHzE_uks5rWj21gaJpZM4Lfgu2 .
thanks for everyone for helping me out
Best Taha Ahmad
On Sat, Jan 28, 2017 at 12:03 AM, George Ciprian Vilau < notifications@github.com> wrote:
Well...they said that you don't need that anymore. So i haven't put it anywhere, and it still worked.
2017-01-27 20:55 GMT+02:00 Gabor Varadi notifications@github.com:
I think you also need to call Realm.setDefaultConfiguration(), but yes
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <https://github.com/realm/realm-java/issues/4010#issuecomment-275744305 , or mute the thread https://github.com/notifications/unsubscribe-auth/AT4b3XC3FZLs- 38MlGuTIU1V9VvHzE_uks5rWj21gaJpZM4Lfgu2 .
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/realm/realm-java/issues/4010#issuecomment-275746310, or mute the thread https://github.com/notifications/unsubscribe-auth/ATtVWQfXQMMtQoXAgvNfNjuFI9yibXfkks5rWj-JgaJpZM4Lfgu2 .
he hi .... ciucurashu i have same problem which you explained above .... I am unable to put Realm.init() in my code so plz help me to slove it . In below i send u my git hub project link plz check and give me solutio
Well after you followed the steps from above you should go inside your DialogAdd class inside the addAction() method and delete those two lines:
RealmConfiguration configuration.... And Realm.setDefault....
Only keep the Realm realm = Realm.getDefaultInstance()
This is what i remember doing. Unfortunately i've lost my code due to some hardware problem:)).
Pe 1 aug. 2017 09:35, "Gabor Varadi" notifications@github.com a scris:
see #3472 https://github.com/realm/realm-java/issues/3472
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/realm/realm-java/issues/4010#issuecomment-319281519, or mute the thread https://github.com/notifications/unsubscribe-auth/AT4b3SXO3QVQXc0c5g__M4zMMT1erDj8ks5sTsdLgaJpZM4Lfgu2 .
private void addAction() { // get the value of the 'goal' or 'to-do' // get the time when it was added String what = mInputWhat.getText().toString(); long now = System.currentTimeMillis(); RealmConfiguration configuration = new RealmConfiguration.Builder(getActivity()).build(); Realm.setDefaultConfiguration(configuration); Realm realm = Realm.getDefaultInstance(); Drop drop = new Drop(what, now, 0, false); realm.beginTransaction(); realm.copyToRealm(drop); realm.commitTransaction(); realm.close();