SQLite why are we copying db to assets folder
There is confusion.
In many examples I've found that they copy database
to a folder assets
.
I don't know why they do. And what is the use of this.
someone will explain this.please
Thank.
A database with default data and table structure is often pre-created and included in the assets folder. We then copy this from the assets folder to internal or external memory at runtime, since the assets folder is only ready after compile time and we cannot modify the data in it. Therefore, in order to be able to write our application to the database, we must first copy it to a portion of the available storage.
Sometimes you can have a db with prepared data. Think about an address book, or a zip code. If you don't put this information in your assets folder, creating basic information will be painful (of course, you can get data over the network, but it is not)
There are several good reasons like:
1. Easily create your database outside of Android
envirnment using some kind of GUI tool like SQLiteBrowser
etc.
2- If you want to have some data default
, you can do it easily. You can paste paste your deafness data out Android envirenment
.