Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite why we copy db in assets folder

Tags:

android

sqlite

There is a confusion .

In so many example i found they are coping database in assets folder.

I don't know why they are doing .and what is the benefit of doing that.

will any one explain this.please

Thanks.

like image 607
Monty Avatar asked Jul 20 '26 07:07

Monty


2 Answers

A database with default data and table structure is often prebuilt and included in the assets folder. We then copy this from the assets folder to the internal or external storage at runtime, as the assets folder is ready only after compile time, and we cannot modify the data in it. Therefore, to be able to write to the database form our app, we must first copy it to a part of the storage we can access.

like image 142
Raghav Sood Avatar answered Jul 22 '26 20:07

Raghav Sood


Sometimes, you may want to have db with prepared data. Think about address book, or zip code things. If you don't put that information in asset folder, building basic information would be a pain (Of course, you can get data via network, but that's not the point)

like image 40
Changyeop Kim Avatar answered Jul 22 '26 22:07

Changyeop Kim