Cordova auto update application folder - android

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

cordova-app-loader is an easy to use plugin to update app files via 3 simple steps:
check() for a new manifest
download() files
update() your app!
It supports android and iOS

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).
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.
When you check for updates, you download new files to you app location and next time application will use these files.

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

Related

How update a single file installed in the APK while developing an app on Android?

I am developing an Android application that has a NDK .so file which I need to iterate on and fix + improve.
The current workflow has me having to generate a APK and install it every iteration which updates a whole plethora of non NDK elements in the process really slowing things down.
The question is how could I access the installation folder of my own APK? I have both a rooted and unrooted device.
Is there some change I could make to install the app in an unprotected location for development purposes even. The installation data is my own application after all so feels like should be a way...
Help greatly appreciated :)
EDIT1:
I found Unity3D has some sort of patching mode, maybe this is a sign that with the correct ADB commands it may be possible... https://docs.unity3d.com/Manual/android-AppPatching.html
EDIT2: I found the location of the .so I am building in... checked on unrooted device and don't have permission.
If your app is not a native-only app (has a Java/Kotlin part) then your so library should be loaded at the moment using a call to System.loadlibrary(..).
What is interesting on this method is, that calls to this method are ignored if the library to be loaded has already been loaded. So if you modify the Java code of the development build of your app to manually load your library before the original loadLibrary call is executed you can end up with a different library loaded.
The only problem is that System.loadLibrary(..) does not accept a file-name or path as argument. But using System.load(..) which uses a full path as argument you should be able to specify a full path to a file e.g. in the app's data directory. That way you can replace the library as often as you want and then just restart the app to load the updated library.

I want to replace database file of an app made by me through another app

I have to replace a file generated by an apk in users device with another file in particular versions of current app.
I have no idea how to accomplish this task in android.
Can i make app B which when run replace the file of App A from App B??
No, it is not possible. Instead of that just provide the update of app A and do the same stuff. Then you are able to do the same.

Android APK using external data

Hi i am looking into an android development , as we all know when we build the project it makes an APK that is the whole program. but is it possible to make a an android project / APK that would be able to use external files to include more info into the project.
like say for example i have a list commands or functions in my list , but i dont want it to be added into my APK build , is it possible to use it externally?
i was curious because something like COC and other games after downloading it , then downloads extra data from the net , more into updates for the whole game.
how is this possible or is it possible to do , and use functions or source codes externally and not include it into the APK , and also the proper usage of it
Any Android App can connect to the Internet and save downloaded data files to use as they need, without requiring to include them inside the APK. Indeed, for many games (and other Apps having large data sets), it's a sensible option.
There are a couple of things to be aware of:
Android restricts where (on the filesystem) you can save files. And no matter where you save the files, the user can delete them at any
time. Your App should be able to cope with this.
The files should only ever be data files - not executable code. Attempting to
execute downloaded files is likely to put your users at risk
(depending on the permissions your App was installed with) and is also likely to get your App marked as malware.
You should read the Android documentation on Data Storage to learn a bit more about it.

using html as front end and text file as back end can save the data in android

My requirement is doing a project with android, now I developed the project in asp.net and call the URL in android web view. It works fine with the internet connection, but when internet is not available the problem occurs, what I have to do?
using html as front end and text file as back-end can save the data and sync when internet connection available, Is it possible?
or any other easy method to do?
please provide some suggestion.
Yes. You can do what you said. You could have a local copy of the web inside the app assets folder and, for example, you can load it like this:
webView.loadUrl("file:///android_asset/web/index.html");
Then you will have to implement an automatic downloader for the new online version. You could do it by putting a simple txt file with the current version (that you have to compare with the one in the app assets) or you could do a restapi that also handles the download (that's the better way, but it needs more time obviously).
Also, you have to write the files you download (for the new version) to the app internal memory (you could get the folder with "context.getFilesDir()") and then check if there is a version of the webapp inside that folder and if not fall back to the one in assets directory (that's included with the app apk).

Access internal files after built - Cordova

I am wondering if is possible accessing the internal files of an app after build with cordova plugin.
My project is based on Android and here are my files:
index.html
html:
- remove.html
js
css
So, after build the app, I want to access with some option within the app the remove.html and remove it.
I find that the FILE plugin of cordova is useful for files inside the device but not the app.
Please anyone has any idea?
we do not have modification access to the location where apk's internal files are saved. Since your remove.html is part of your app apk, we cannot just remove it.
You can take the same approach taken by sqlite raw database file. When your app is started or run for the very first time, copy your file (remove.html) to data folder where you can modify/delete it. Make sure your app only uses this new path everywhere.
Take a look at copyDatabaseFromAssets function in this code for a sample on how do this. Since you will have modification access, you can delete or modify this file as needed.

Categories

Resources