Can a app modify files in the assets folder?


#1

Within the app’s assets folder I hold various json files representing the data used by the app.
Assuming there is a new version of that data file on the server - is it possible to download the file (easy - just use http) and replace the file in the asset folder.

I guess what I am really asking is

"Does an app have write access in the asset folder?


#2

No. The “asset folder” doesn’t really exist independently after the app is built - it is burned into the app binary itself.


#3

Thanks @rapropos - in that case I will just have a extra file on the server for changes to the json files and hold that data in local storage.


#4

That sounds like a good idea. If you want to get fancy, you could make an asset provider (similar to ngx-translate) that seamlessly reads from either the locally modified version or, as a backup, whatever is in assets. That way all the information about how you are handling the situation is (a) isolated from the rest of your app code and (b) futureproof.


#5

Sounds good - but for now I can cope with a simple approach - besides I am not sure I will keep using Ionic in the future - Ionic 4 is a totally unknown factor and I worry how long it take to clear all the bugs when used for real in production.


#6

Alternative, more laborious and for the record, is to create a cordova plugin athat writes the stuff

Like phonegaps contentsync plugin or ionic’s deploy plugin

These write into the asset folder and can check for updates under the hood