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.
Related
I have an android app which allows the user to gather research data. I want to export the gathered data as an excel file. So the user can work with the data on a desktop computer.
The question is, what is the best way in terms of usability to offer file export to the user?
On idea was to start the email client with the excel file as attachment. But if you have to send this email to yourself just to get the files seem kind of a workaround.
The second idea is to store the file in the android file system. But is there a commen folder for something like that? Like the "Documents" folder in windows? I dont want the user to search too long for his file. And is this really best practice?
The common way, is using the shared intent system and allowing the user to pick which app "he" or "she" wants to use to share the file. You can also save it to the android file system just as easily. There is no common folder which everyone should use. But if you want ease of accessibility for the file, create a new sub-directory under the top-level directory on the device. Use this method to get a reference to the top-level, Environment.getExternalStorageDirectory(). You must have the android.permission.WRITE_EXTERNAL_STORAGE permission declared in your app Manifest. The sub-directory name should be something obvious to that user that the data inside belongs to your app. Furthermore, display a toast that indicates to the user where the file is stored to make it even easier for them.
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.
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 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'm coding an android app for parsing sms messages. I need different rules for different countries and idea is to define rules for my country and later open source project so other users can contribute with rules for their countries. XML format is the most convenient in my opinion for defining these rules.
So I have an app which reeds rules from XML file stored in res/raw and users will later be able to update that set of rules or download rules for some other country when those become available.
As I said I have put existing XML files in res/raw, but the problem is when users download new or changed set of rules application can not change or store files in resources (correct me if I'm wrong).
So I have two options now, and I don't like either one. I would like to hear your opinions on the matter.
a) I can keep XML files as local files, but then I must read in default rules from res/raw and copy them into file system on application installation, or keep track of two separate bunch of files. Is it possible to preinclude files on file system when installing an app?
b) I can keep XML code in database, but also copy it from files at install time. Or even worse code XML as String in class to insert it on install?
I apologize if question is too long or unclear, English is not my native language and this is my first question.
I'm not sure if i understood you right, but you could store the XML-file in the internal data storage of the application. --> http://developer.android.com/guide/topics/data/data-storage.html
If you want to attach a first Version of the XML-file on install, store it in the ressources first and copy it to the internal data storage after install. On updates of the XML file you can just overwrite this file in the internal data storage.
Hope i could help you, this is my first answer on stackoverflow. I'm sorry if i just told you things you already knew.