A
A
atomnato2021-10-01 02:53:50
Android
atomnato, 2021-10-01 02:53:50

Database storage?

Usually, when creating a database, the path where it is stored is "data/data/YOUR_PACKET_NAME/databases/YOU_PROJECT_TITLE". The question is: Is it even possible to add your db file directly to this path in the project files, thereby avoiding the creation of a database inside the application. If so, why doesn't anyone do it?
PS I have seen implementations with adding a db file to the assets folder, after which, again, the database created inside the application was overwritten using the file added to the database. But I'm interested in adding my own db file directly to the above path. Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alekseyHunter, 2021-10-07
@atomnato

Keeping the database on the client side is a pleasure.
First, you will need to ask the user for permission to read / write data from the device. After this request, the user will delete the application with a 99% probability, unless it is a super-necessary application without analogues or the application's functionality provides for working with files. Well, if you do not provide permission, then your application simply will not work. And it will also be removed.
Secondly, the database is used not only for reading, but also for writing. What will happen to the saved data if you roll out a new version of the application?
A real example, now in one of my applications, the local database contains IDs of localized strings (translated into several languages), so after each new string is added to the resource file, all IDs disappear, and all values ​​in the database become irrelevant. I have to do a data migration after every update.

O
Oleg, 2021-10-01
@402d

the screw with a hammer is also easier to score.
Think about how you will do migrations with this approach.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question