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.
Related
First, let me say that today is the first time I've ask a question on SO, so please be tolerant if I don't phrase my question according to the rules or make myself clear. I have reviewed these problems in SO and can't seem to find an up-to-date solution THAT ACTUALLY WORKS.
My problems deal with creating and accessing files being transferred between Windows and Android 11.
I have an android karaoke app that reads karaoke files previously transferred from Windows. I manually created a 'Karaoke' folder on an external SD card and manually copied the karaoke MP3 and CDG files into that folder's sub-folders. I was then able to programmatically access those files within my app. Under Android 11, I can still access the MP3 files but not the CDG files. What is the best option to solve this problem.
Likewise, I was backing up my app database located in protected storage to the removable SD card. I could then manually transfer the backup files to Windows. This no longer works under Android 11. What is the best option to solve this problem.
I have commercial tablets running on Android 4.4. I made a simple app with some buttons, video's and txt files. The video's and the txt files are stored on the external sd card so I can change the content without changing the app.
In my code I used (AIR SDK as3):
"file:///mnt/external-sd/folder/";
as reference to the folder. But on the newer commercial tablets Android 7.1.2. is running and this doesn't work anymore. I tried to change the filepath in 100 different ways based on what I found online what this could be.. It is making me nuts.
I have set the write and read permission, just to be sure, in the manifest (I didn't needed them in the older version). But nothing changed...
I think something else might be the problem? Am I missing something?
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
Before Android 4.4, we could easily delete files from any sd card directories. After 4.4 this is removed, even with WRITE_EXTERNAL_STORAGE permission you couldn't do it (except with some hacks with ContentProviders). But I heard after 5.0 this ability is re-added (don't know if it's wrong). I tried File.delete() method but it's no different than 4.4 for me. Is there any way of deleting a file from sdcard in Android 5.0+ ?
You can request permissions from the user to the sdcard through SAF:
How to use the new SD card access API presented for Android 5.0 (Lollipop)?
I was also facing the same problem in my Android version 5.0 but now I have no worries regarding this as I found the solution of this problem. Just do as I said: go to playstore and download "X-plore File manager" and delete whatever you want from your external storage as well as internal storage.
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.