Android: how to identify modified files on sdcard? - android

My android app is saving some file on the sdcard / external storage. Some of these files may then get modified by the user outside the control of my app.
At a later point I would like to identify which files were modified since they were initially created.
Normally this would be easy: simply check the last modified time. Unfortunately an android bug prevents changing the last modified time of existing files.
How does everybody else work around this problem? Clearly cloud sync apps like Dropbox etc have found a way. Do I really need to calculate a hash for every file just to find out whether it has changed?

Related

Android: Keep internal files after updating app

I've seen multiple instances where people claim that updating an Android app does not remove its internal files. However, I'm reading and creating a file using openFileInput() and openFileOutput() respectively, which works fine, until the app is updated where apparently the file can not be read, or is deleted.
As I'm developing a game, I would like to avoid SharedPreferences.
As saving progress is more or less mandatory, would writing to an external location be a better alternative? The user shouldn't although be able to tamper with the file (its a serialisation).
Otherwise, is there a way to keep the internal file after updating? Thanks
Why do you not use an SQLite database for this purpose. Updating the app will leave the database untouched unless you explicitely instruct your app to change or delete it.

Android Downloaded Files Reported Missing

We have built an android app that lets users download content from an http endpoint. The downloaded file is stored via Context.getExternalFilesDir(null) if the external drive is writable otherwise we use Context.getFilesDir() to store internally. In either case, we store the absolute path to a database (which could point to an internal or external file path) so we know how and where to find it later.
We've received a number of emails to our tech support saying that after they close and reopen the app that the files are gone. The people emailing with the problem don't have exact steps for reproducing but that has been their experience. No one on our team has been able to reproduce the bug, but it gets reported consistently.
The same people reporting the problem say that they are able to use the files when they download them. The problem is that when they come back to the app later they have to re-download them.
Am I missing something that the framework is maybe doing to delete the files on certain devices/versions?
I think some might jump to the conclusion that it's an external path issue. Meaning it gets saved there, and when they want to access it later the drive isn't mounted any more and therefore the file is "gone". We have a setting the user can check to force downloads to be saved via the internal method (which tech support has them try) Context.getFilesDir() so I don't believe that would be an issue.
I know this is quite vague but I've been getting nowhere now for quite some time. Perhaps some thoughts on storage in general would be helpful. How have you handled storing internal and external files?

deploy extra data files to deployed android app

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!

Start Android app with files on sdcard or somewhere in the filesystem

I making an application with phonegap/cordova where I need to keep a lot of files up to date. Some files (mainly images) will need to be erased in time, and some new ones will get downloaded. The thing is, in Android, to manipulate those files, it seems I need to have them on the sdcard; so I copy the files the app starts with from my assets folder to the sdcard. It just seems like a waste of memory space.
Do you know if is there anyway I can start with the app having those files the app starts with already inside the sdcard? or at least somewhere I can delete them later?
Thank you.
Files that are delivered to the device as part of your APK will be stored in a form that cannot be modified by your application (other than by updating to a new version of the apk).
If you copy the files out of the APK into the private internal storage area or the external storage area, those copies can be modified, but the originals inside the apk will remain.
The most efficient solution may be to not put these files in your apk, but have your app instead download them separately on the first run, using whatever mechanism you wanted to use to change them in the future.
(Some people object to this feeling that such files are less secure against unauthorized use, but as the contents of an .apk are trivial to extract this is not a strong argument. Needing to maintain a server to download from is a slightly more substantial objection.)
You do not need to store the files on the SD Card. Each app has its own internal storage that is not accessible by any other apps. For more information see the official docs: http://developer.android.com/guide/topics/data/data-storage.html

Distribution a file with my android project that will be updated in the future

I'm creating a simple Android App, it will be a map with a number of points marked on it. These points will sometimes change, based on an XML file hosted on the internet.
To reduce the initial load time my intention is to distribute a serialized List of these points with the application that can be updated in the future.
At first my intention was to distribute this serialized file as an 'asset'. This way I could just generate the file and drop it in to 'assets'. However, this does not work because (from what I can see) it is not possible for me to overwrite these assets.
The second option was to use the internal storage, however (from what I can see) I can't distribute this file as 'internal storage'.
Is my only option to distribute my serialized List as an asset and then on the initial load copy it to the internal storage? The files only going to be around 50kb but it seems unnecessary to have 2 copies of the same file (1 of which will eventually become outdated) as part of the same application.
How about always first checking the internal storage and if your data does not exist there read the 'asset' version.
Then you will have a syncronization job that will download the updated file (when available/updated) and put it in internal storage. But yes I guess you will be stuck with always having the original file there.

Categories

Resources