In an earlier chapter, we explored
createFromAsset() as a way to set up a Room database from an existing database copy, in this case packaged as an asset.
There is also
createFromFile(). This works just like
createFromAsset(), but it takes a
File parameter that should point to a readable file containing the database copy.
For restoring from a backup or importing from a database, this is more convenient than is the manual-copy-from-a-stream approach used in this chapter’s sample. However, it only works with files, which is an unfortunate limitation. The sample uses
File, to identify the location of the backup, and so
createFromFile() is not an available alternative.
Prev Table of Contents Next
This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.