Pergunta

I have an app that needs a pretty large database for information on locations and pictures for these locations. I want to have the database online and download it to the app on first run. Question is how do I download the file from the bucket without making it public from the application?

Foi útil?

Solução

Since you want to use a pre-populated database, I suggest you consider using SQLiteAssetHelper. This library will take care of creation(once on open), and has version/upgrade capability too.

To use google cloud storage with this library, take a look at the function copyDatabaseFromAssets in this link. You will create a new function, may be copyDatabaseFromGCS, which will download your database file from GCS and open it as an InputStream and copy it to local database file (similar to the code in copyDatabaseFromAssets function). This download happens only once, and has version/upgrade capability same as local assets based database of SQLiteAssetHelper library.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top