Home > Back-end >  Connecting tables of two or more databases with each other in android studio
Connecting tables of two or more databases with each other in android studio

Time:02-08

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 "   ")";

CodePudding user response:

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.

CodePudding user response:

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

  •  Tags:  
  • Related