1. Are you ready for the Galaxy S20? Here is everything we know so far!

Your thoughts on best way to manage a multiple DB App

Discussion in 'Android Development' started by Guitarist, Jan 3, 2020.

  1. Guitarist

    Guitarist Newbie
    Thread Starter

    I could use some thoughts/suggestions on "what may be the best approach to handing multiple SQLite DBs for an Android app based upon a template DB?"

    About the existing app - representing the issue of handling multiple DBs in Android:
    As brief as possible, I have an existing Java-based Research DB app that allows a user to create a subject oriented database for research that requires the user to document a source for each note on a subject. A subject would be a single database. (blank.zip attached contains SQLite db examples)

    So there is a blank template database (i.e. blank.db) that is copied and renamed to the subject the user chooses to research. The SQLite template database contains 11 tables, 10 relation-ally linked to a Notes table. The remaining 10 tables are Sources, Authors, Author_by_Source, Comments, Quotes, Terms, Topics, Files, File_by_Note, Questions.
    However, a user can delete, export, or import any database they wish except the blank.db and sample.db which come with the app.

    What have I done:
    I've have been reading and doing hands-on tutorials learning the Android C.R.U.D approach through the DatabaseHelper. I've also learned about the Asset folder and storing databases already created within a sub folder called databases. So this where I ask my question(s).

    So the Discussion Questions:
    What is the best way to handle creating new databases?

    Can I manage everything through the Assets folder?

    Attached Files:

  2. Best Answer:
    Post #2 by Deleted User, Jan 3, 2020 (1 points)

    1. Download the Forums for Android™ app!


  3. Deleted User

    Deleted User Guest

    It's your lucky day. I know the perfect architectural pattern to handle multiple data sources. And it even follows a recipe for you to cut and paste code straight into your app.
    Forget using SQLiteHelper classes. Use Room, an object/database mapping library.


    This architecture involves using a 'repository', which is a data layer that can handle multiple data sources. It also includes a pattern for observing live data, so your UI layer can automatically show the most up to date view of the data.
    Unforgiven likes this.
  4. Guitarist

    Guitarist Newbie
    Thread Starter

    Ha! So it is my lucky day!

    This is cool, thanks for this suggestion. I've been doing the tutorial and any question I had previously was answered!

    Again, thanks for taking the time LV426!
    #3 Guitarist, Jan 6, 2020
    Last edited: Jan 7, 2020
    Deleted User likes this.
  5. Julia Smith

    Julia Smith Lurker

    I ll love to give my thoughts on this, establishing connections to multiple databases is not a trivial task because each database product implements its own connection parameters. For instance, some databases require a default database, whereas others do not. Navicat smooths out these differences by providing a consistent Connection dialog for each database type, with only a few minor variations between screens.
    Sam billings likes this.
  6. Guitarist

    Guitarist Newbie
    Thread Starter

    Hi Julia!

    Thanks for sharing your thoughts and I will read up on Navicat. In the app currently operating, opening and closing multiple databases, and cleanly was difficult.
  7. Sam billings

    Sam billings Lurker

    I was also researching about this topic & ll love to add more, the DBA’s role is becoming increasingly complex and now often involves managing data both on premise and in the cloud, and in a variety of database management systems including not only traditional relational systems such as Oracle, SQL Server, MySQL and others, but also new open source and NoSQL technologies. It may sound crazy at first, since most of the Rails applications we tend to work with connect to just one database. But, it actually isn't that unusual to have a single app communicate with more than one database. I will sure go through on Navicat & other sources suggested by Julia & other members.
  8. Guitarist

    Guitarist Newbie
    Thread Starter

    LV426, Julia and Sam;

    Thanks for all the suggestions. It will take some time to learn what the best of these options may be. Hopefully this post will be resourceful to others in the future.

Share This Page