skip to Main Content

I just wanted to know if there is any way to connect two tables of two different databases under one project.
I have the databases as follow

First database

private String CREATE_USER_TABLE = "CREATE TABLE  "+ TABLE_USER + "(" +
        COLUMN_USER_ID +" INTEGER PRIMARY KEY AUTOINCREMENT , " + COLUMN_USER_MOBILE + " TEXT," + 
        COLUMN_USER_EMAIL + " TEXT, "
        + COLUMN_USER_MOTHERNAME + " TEXT, " + COLUMN_USER_FATHERNAME + " TEXT, " +
        COLUMN_USER_PASSWORD + " TEXT, " + COLUMN_USER_CONFIRM_PASSWORD + " TEXT " + ")";

Second database

        private String CREATE_BABY_TABLE = "CREATE TABLE "+ TABLE_BABY + "(" +
        COLUMN_BABY_ID + " INTEGER  PRIMARY KEY AUTOINCREMENT , " + COLUMN_BABY_NAME + " TEXT, "
        + COLUMN_BABY_DATE + " TEXT, " + COLUMN_BABY_GENDER + " TEXT, " + COLUMN_BABY_AGE + 
          " TEXT " + ")";

2

Answers


  1. Yes, application can has connect to different databases. (By clear sqlite or any db library, like Room)
    But your question contains two tables but not two databases. You must just put them to one database.

    Login or Signup to reply.
  2. The standard solution to this is to query each of the databases separately and then merge or join the results in your application logic.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search