I want to add SQLite
database inside an apk
file when generating the apk file
so that when I install the apk
on the phone, the database to be inside the apk folder
of the app. For example if Cpodo.Cpodo
is the name of the apk folder
, I want after installation the SQLite
database file (speakers.db
) to be inside the apk folder
like that:
Answers
We could embed a .db file in the project under
Assets
folder and access it through:So it is impossible to add a file into an
apk file
when generating it? If I want a file to appear in the phone when I install anapk file
, I must put that file inside theXamarin.Android
project (in Assets folder for example), if it's yes, where do I look for that file in the phone after the instalation of theapk
or after the deploy of the project?We need to start from the programmatical side. Once we put the file in the project, it will be compiled into .apk.
We can't individually add an extra file when generating .apk file.
If we put
sample.db
inside theAssets
folder of the project where do I look forsample.db
in the phone after the installation of theapk
file or after the deploy of the app. I looked inside the apk folder of the app but it wasn't there.You could store it on the local storage after enabling the write external storage permissions.
And then we can find it on your phone in the storage.
May I ask why you want to embed this file in .apk?
We definitely could achieve it through other approaches instead of the hacky one.
I wanted to embed the database file into the apk because I was asked to do it that way by person who ordered the project.
The files in the project will all be packaged into .apk.
I still can't understand why do you want to embed it directly into .apk. And we can't do it programmatically.
We could manipulate the files in the application and store them in the external storage if you want.