I have two instances of SQLiteDatabase database. And I need to copy data from one to another.
I need to execute this query:
INSERT INTO `toDB`.`tableName` SELECT * FROM `fromDB`.`tableName`
so, How can I do this my database instances? How to replace toDB and fromDB ?
Never tried that but it should work this way:
you have to ATTACH the other database at SQLite level so sqlite can access it directly.
For example you open the database that shall be the
toDBand you issue the following command (viaexecSQL)you should have access to the other database now and can do
the database you opened originally has the name “main” automatically.
You can and should get the path to your databases via Context#getDatabasePath since there is no guarantee that this path is the same on all devices.