diff --git a/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java b/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java index eea98e9..5e7cd07 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java @@ -55,7 +55,7 @@ public class DrugDetailActivity extends AppCompatActivity { public void onClick(View view) { Log.d(TAG, "Click on save icon"); - getMDrugChanges(); + getDrugChanges(); setResult(1); finish(); overridePendingTransition(R.anim.slide_from_left, R.anim.slide_to_right); @@ -107,11 +107,10 @@ public class DrugDetailActivity extends AppCompatActivity { return super.onOptionsItemSelected(item); } - private void getMDrugChanges() { + private void getDrugChanges() { Log.d(TAG, "Time to save new values"); - PrescriptionDatabase prescriptions = null; - assert false; + PrescriptionDatabase prescriptions = PrescriptionDatabase.getInstanceDatabase(this); PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO(); Prescription newPrescription = prescriptionsDAO.getMedicByCIP13(aPrescription.getCip13()); diff --git a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java index 6906407..628f7fb 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java @@ -93,17 +93,10 @@ public class DrugListActivity extends AppCompatActivity { } // Create medicines Room database from drugs.db files - medicines = Room - .databaseBuilder(getApplicationContext(), MedicineDatabase.class, "medicines") - .createFromAsset("drugs.db") - .allowMainThreadQueries() - .build(); + medicines = MedicineDatabase.getInstanceDatabase(this); // Create prescriptions Room database - prescriptions = Room - .databaseBuilder(getApplicationContext(), PrescriptionDatabase.class, "prescriptions") - .allowMainThreadQueries() - .build(); + prescriptions = PrescriptionDatabase.getInstanceDatabase(this); // Manually migrate old database to room PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO();