Home » Android » android – Cordova auto update application folder

android – Cordova auto update application folder

Posted by: admin June 15, 2020 Leave a comment

Questions:

I have an offline application cordova, composed of simple html and pictures, all inserted in a sub folder (android_asset/www/app). I would like to add a second online application (android_asset/www/update/) that, check for update, download and replace the first. Is this a reasonable solution for in app synchronization?

Thanks for the time

How to&Answers:

You could achieve desired functionality if you will use Cordova File Plugin.
Main trick is to load files not from android_asset/www/app, but from location on the phone storage, using cdvfile protocol (which point to the file location on the phone SDcard).

  1. When you application starts first time, you will go to you server and save latest app version to the phone storage, and then launch you app logic code from there.
  2. When you check for updates, you download new files to you app location and next time application will use these files.

Answer:

cordova-app-loader is an easy to use plugin to update app files via 3 simple steps:

  1. check() for a new manifest
  2. download() files
  3. update() your app!

It supports android and iOS

Answer:

Cordova Hot Code Push plugin also seems to address that matter. Its code seems much cleaner than cordova-app-loader and easier to use.