I am Converting CSV file to realm file on APP ONE then shipping this as the primary database in the APP TWO and setting as default database using
SharedPreferences wmbPreference = PreferenceManager.getDefaultSharedPreferences(this);
boolean isFirstRun = wmbPreference.getBoolean("FIRSTRUN", true);
if (isFirstRun)
{
RealmConfiguration config = new RealmConfiguration.Builder(context)
.name(Realm.DEFAULT_REALM_NAME)
.migration(new in.webic.oralcalculations.Row())
.assetFile(context, "Default.realm")
.schemaVersion(0)
.build();
realm = realm.getInstance(config);
realm.close();
SharedPreferences.Editor editor = wmbPreference.edit();
editor.putBoolean("FIRSTRUN", false);
editor.commit();
}
and default.realm is saved in the app directory
in my another activity i am trying to use this db by
public void prepare_test(int id){
realm = realm.getDefaultInstance();
RealmResults<RowNew> result2 = realm.where(RowNew.class)
.equalTo("course", id)
.findAll();
String a="";
for (RowNew u : result2) {
a+=" "+u.getQp1();
}
Toast.makeText(this,a,
Toast.LENGTH_LONG).show();
}
giving me error
No default RealmConfiguration was found. Call setDefaultConfiguration() first
yet i have already shown the creation of the default db in the app
any help will be appritiated
thanks
You need initialize your realm default config as you doing this in first application. It's required even if you mannually transfer database file