-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty DB after application restart #1432
Comments
Sorry to hear that! Could you possibly share your project? maybe privately if needed to help@realm.io. That would make it super simple to help you. Alternatively try to share all relevant Realm code here. |
Sorry but application is under NDA and very big... but i`ll try in CustomApplication extend Aplication private Realm realmDB;
public void onCreate() {
super.onCreate();
realmDB = Realm.getInstance(this);
}
public Realm getRealmDB() {
return realmDB;
} in first activivty Realm realm = ((CustomApplication) getApplication()).getRealmDB();
realm.beginTransaction();
realm.copyToRealm(theme);
realm.commitTransaction(); theme is not null CustomizeTheme class in other place realm = ((CustomApplication) getApplication()).getRealmDB();
realm.where(CustomizeTheme.class).findFirst() |
Given the code you have provided it should work, so most likely you are deleting the object in some other piece of the code. Have you tried putting a test directly into your custom application to check? Something like:
|
I'll test it on Monday
|
3152-3152/? I/Test﹕ No theme So where could I delete it? |
Hi @HellAvalor Some places to look
Also if you have some code that is interacting with your apps files. Realm will save the file in |
I found problem... I`m clearing files from data/data//files/ directory after init of realm and RealmDB is working from memory but not storing anything to disk because of no file there. So it was hard to find problem, because that is not directly connected to RealmDB. it was like public class MyApplication extends Application {
private Realm realmDB;
public void onCreate() {
super.onCreate();
realmDB = Realm.getInstance(this);
String sdcard = getFilesDir().getPath();
File fileList = new File(sdcard);
// so we can list all files
File[] filenames = fileList.listFiles();
// loop through each file and delete
for (File tmpf : filenames)
tmpf.delete();
}
} Thanks. |
Ok, great you found it. A few notes about your code. |
@HellAvalor I'll close this issue now. Feel free to open another use if you run into any other problems with Realm. |
Hi everyone.
I've ununderstandable problem with storing.
like realm = Realm.getInstance(this);
I`m not deleting realm, not clearing it, not clearing cache. So what is it could be?
realm version io.realm:realm-android:0.82.1
The text was updated successfully, but these errors were encountered: