I have a xml file which contains editable patterns (these patterns represent audio rhythms). When the application is first installed, it comes with a default xml file, the user can edit the patterns in this file through the android application. If an user updates his android application, is there a way to ensure that the edited xml file is preserved?
You can copy the editable file to your application's internal storage (or download it there directly) the first time your app runs.
Post that, as long as the user does not clear data or uninstall and reinstall your app, this copy of your file will persist across updates.
Related
What does "lastmodified" describe? Just the file's content or also file system related things like file name and Path?
My interest goes especially for the Android platform. I will store data in my app's directory. A quick test showed, that a Samsung Android device with Android 4.2.2 does not change the date when moving files with the build in file browser.
from my experience it doesnt change it. After such operations I manually do
file.setLastModified(System.currentTimeMillis());
Consider an app with a set of data files (could be music or pictures or locations or indeed anything at all) embedded in the apk.
I now want to provide to the user additional data files , either to replace or add to the original data files - the user should be able to select which files to download and not have to reinstall the whole app.
So the question is it possible to do this non-programmatically - like by providing extra apk files for the app but which only contain single data files?
This is a good use case. A simple idea could be, ask the user to check for updates, you download a XML file which defines your updates. Parse this XML file and show what the user needs to download. Then you download and save it to desired locations. Always version the XML file so that you know if updates are avialble or not!
I'd like to know if there is any way to update a specific file in the package (apk) that was originally shipped?
In my case I need to make sure that a certain text file comes with the app when downloading the apk. However, I want to be able to update that text file remotely and replace only that text file, not the entire apk-file.
you can write and create files that are in the so called "internal storage", but how do I place the text file there in the first place; that is, how do I make sure that the text file is in the "internal storage" so I can read it with openFileInput(...) after the install of the apk?
Because if I can place the text file in "internal storage" so it can be reached by openFileInput, I can easily overwrite it later, but then it has to be there in the first place =).
If you want to be able to update the text doc without updating the entire apk each time you updated the text doc, then you will need to host the text doc on a website and have the apk fetch the document. You could create an alarm to fire off and then have a broadcast reciever retrieve the document and store it to the app. Or you could have the text doc on a website(google site is free) and have the app read from it, and store the data in a SharedPreference.
If you need code on how to read from a text doc let me know. As i use this process for one of my apps. It works perfect.
I am currently programming an "One time after first login tutorial" and since it should be only shown one time after the user starts the application for the first time, I would like to remove all the unnecessary files like for example pictures which I only use in this tutorial.
So is there a way to remove some of these files which are shipped within the .apk ?
The Android apk is a read only file, so once a file is part of an apk, it cannot be removed.
An option would be to download the files from the network the first time the user installs the app and then put it on the sd card or locally and then delete it when you want it.
I want to decouple data from code on my Android application, and I am not sure of the best way to do that.
For instance - with the Linux Mahjongg game you can add new tiles to the game by dropping a specially formatted file into a specific directory. The Mahjongg game checks that directory when it starts up.
I want to do the same thing with my Android app - I want to be able to install the app, and then have separate installs for different data files. It's the data file installs that have me hung up. I do not want to have to set up my own server and write my own download code.
You can ship the data with the installer app, then use Input/Output Streams to copy the data from the assets or raw dirs.
Check this out:
Ship an application with a database
The answer has an implementation of in/outputstream. You don't need to use a db, just copy the file to ext storage.
One important detail: if you put the file in assets, it will be shipped compressed, and the phone/tab will try to uncompress the file in its entirety in memory. One (hocky) way to avoid that is to name the file .mp3. Assets in .mp3 format are not compressed. (Hey! I said it was hocky!)
The installer app can either uninstall itself by using ACTION_DELETE in an intent (see http://android.amberfog.com/?p=98 for details) or just show a msg to the user that it's safe to delete the data app.
HTH,
llappall
by dropping a specially formatted file into a specific directory
You can do that on external storage. Create a directory, and check it when your app starts up for new files. Tell the user they have to stick the magic files in the magic directory for it to work.