Is it possible to automatically write my own config files upon installation of an APK? How do I do that? I realize this might introduce unwanted bugs as user can change these configs. However, I need this functionality in my Android app. I don't want the application to run first then write the file. What I really want is writing my own config files upon installation. Can anybody give pointers? Thanks.
What I really want is writing my own config files upon installation.
That is not possible. There is no hook in Android to automatically set up some sort of files on internal storage. And, if you are "writing [your] own config files", then by definition, then "the application [will] run first", because your application is where the file-writing code resides.
Configuration files? If its related to the APK of your app then chances are, it is gonna be the run first then write the file. A thing for writing file though is the assets folder that an android project has.
Related
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 am trying to package /somewhere/lib/python3.x inside APK's lib folder like jniLibs. But it contains *.py, *.pyc and other files. I have asked another question, but there is no answer. So this is a general question: do you ever used or developed any plugins that embed non-standard files in APK instead of using assets?
How would you access those files? I mean you could put them in the apk, an apk is just a zip file. But the system won't unpack them for you, and at runtime you won't be able to access the apk file itself (installation unzips your file and deletes the apk). You might be able to fool it into doing so by putting it with the jni libs and hoping it doesn't look at extention, but it seem like a bad idea.
However its not uncommon for an app to take its assets and write them to the filesystem on first boot. In fact its fairly common to do this with updatable assets (you'd then just download new versions on top of them, but you can use the old versions to not need an immediate network connection). This would probably work for you. Just make your initial activity a splash screen, and have it do the copy from assets to files in the background while the splash is up.
I have a question, because when I install app, I create .csv file and it's the most important file for my app. When I use this app I always check is this file exists. I put this file on storage, but when I uninstall this app, this file wasn't removed. It's still exits. So what can I do to remove this file automatically? Thanks for response.
All you need do is to locate the file and delete it manually.
Some apps are built to startup from where you left off, especially apps that have regular updates.
Its just a backup plan.
If you're sure you don't need it anymore, simply locate and delete it.
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.
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.