I'm trying to implement a routine that checks the version of files on the sd card. The app essentially downloads a list of files on the sd card. The files on the server are prone to changes in the future.
How do I manage to check if the app is using the latest file. I thought doing it by forcing the user to reinstall the app and using SharedPrerfernces to store the version of each file, but then when the app is reinstalled the SharedPreferences will be deleted.
Any other way that you can suggest ?
Use the lastModified() method to determine the last time you got the files in question and then check to see if they're older than the ones on the server.
Related
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?
I'm developing application that is targeted for API 18. Application download data by Bluetooth and GSM and stores data on internal sdcard (usually \emulated\sdcard - readed by Environment.getExternalStorageDirectory()).
Till this time everything works fine - files and folders are correctly saved.
Today i've faced very strange behaviour:
1) Started the app, and it works for over an hour and store data files.
2) After that, i've closed app and want to download data to the computer.
Before plugin USB, I've used Android file explorer software to check stored data.
I was shocked - new folder (any new data) was gone!
It's like system removes or hide all files and data created in last app session.
Remarks: application don't have procedures for deletion folder or files. Also it works good on previous versions of Android (mostly 4.X and 5.X).
It's very strange because app has warning mechanism when save isn't possible and that warnings wasn't displayed. So I think, write was allowed by system, but data isn't visible at this moment.
Another stranger thing is that application can't write any file in internal storage from this moment (and the warnings are displayed as should in this case).
It looks like Android Marshmallow "decides" in particular moment - your new data won't be available anymore, and your app won't write to internal card.
I've checked app permissions in system - OK.
Any ideas, why this happens? How to deal with it?
You may refer to these guides for managing permissions during runtime: http://www.howtogeek.com/230683/how-to-manage-app-permissions-on-android-6.0/
https://developer.android.com/training/permissions/requesting.html
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'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.
I've use the Android method Context.getExternalFilesDir() and save some data from my app on a external file. So far, when I uninstall the app on an Android 4.4, this external files are being erased as well, but this is not the case for Android 2.3.
I was wondering if this is possible and if so, how would I achieve this kind of behavior in Android 2.3.
Regards
Jose
4.4 changed the behavior for the SD card. Prior to that, data on the SD card had no protections, any app could read or write anywhere. Afterwards, files and directories were protected so only the app that created them could read or write them. Because 2.3 doesn't track who owns the files, it can't delete them when uninstalling. The closest thing you could do is delete the files yourself on a regular basis.