In Android 4.1,there comes a new option in DEVELOPER OPTIONS called Protect SD CARD.
I've know that ,if we do change this option,some progress will be killed.
Now the question is , how can i know that there's a certain change about this option?
Through which value ,or progress , can i know that ?
thanks in advance.
Not exactly sure what you are asking, be I can guess...
Turning the option on enforces a new permission (READ_EXTERNAL_STORAGE), required to read external storage/SD card. In previous versions, any app could read external storage, and an explicit permission was only required for writing (WRITE_EXTERNAL_STORAGE). When you turn it on, apps that don't have the READ_EXTERNAL_STORAGE permission will fail (crash) with SecurityException. If that is your app(s), simply add the permission. If those are not your apps, there is not much you can do, but ask the author(s) to add the permission in the next release.
If that's what you are asking, I don't think you can check programatically if the option is on, but you shouldn't be doing this anyway.
Related
Is there any way to store a text file without asking permission?
And even if i uninstall the app data should not be deleted..
currently this isn't possible, not on all/newest OS versions. e.g starting Android 10 we have Scoped Storage and without proper permission you can't save files, which won't be deleted with your app removal
developer may opt out from this feature on Android 10, but for 11 supporting it is mandatory
some docs in HERE
I read this post which seems to explain this feature. But, I still don't know few things:
In my file explorer:
When should I ask for this permission
How do I ask (I know the intent->onActivityResult but, how do I check if I have to ask ?)
What do I do when I want to do something with this SDCard permission ?
Thanks in advance
Acolleague just pointed me at this issue. What's the problem exactly? I see in the code that the manifest has:
It also needs the READ_* permission likely. That should give it full access to external storage. Storage Access Framework is a completely different system for interacting with user documents across apps, has nothing specifically to do with write access to sdcard.
And you've always needed that permission to read/write sdcard without root. Old apps didn't have it. The change in KK is that you can now read/write to your private data folder on sdcard WITHOUT needing the permission -- you only need it if you want to touch outside your private data.
So is the real problem that syncthing doesn't USE external storage (sounds confusing, but it only has the WRITE permission), doesn't expose it to the user as a target, or is there simply a bug under the hood somewhere...
Hope that helps!
I need to store the data on the android device and want to access this data from different applications(Through the services in background).
We can achieve this using the External storage. But it may possible that if it is removable then it will not be available when mounted to PC or removed. So, Is there any permanent non removable global storage always available for the all applications on each android device ? If so how I can access it.
Please guide me. Thanks in advance.
But it may possible that if it is removable then it will not be available when mounted to PC or removed.
"mounted to PC" is not a problem on Android 3.0+, though it is on Android 1.x/2.x. And external storage is rarely removable on Android 3.0+ devices.
So, Is there any permanent non removable global storage always available for the all applications on each android device ?
External storage is as close as you are going to get. This means that you may wish to reconsider your original plan. Depending upon the nature of your app(s), the answer may be that one app has the data on internal storage and is making the data available to other apps in your suite via a ContentProvider. This has more fine-grained security possibilities than does external storage.
File system storage will not help you as everywhere your apps can read/write every other app can read/write/delete, too and you end up in a similar situation as on the sdcard section.
BTW: Unmounting the sdcard section when connecting to a PC only works on onld outdated devices. Current devices just use the MTP protocol, which allows access from Android and PC at the same time.
If several apps are working together there a many ways for sharing data among each other:
Use the sharedUserId feature in each app (AndroidManifest.xml).
Make one "storing-app" that has one or more Provider for accessing the data from different apps. Secure them using a self-defined permission.
You can use the internal storage with FileOutputStream, as it's explained here in the documentation.
By default, those files are private to your app, but you can change that with the Context.MODE_WORLD_WRITEABLE or Context.MODE_WORLD_READABLE.
But please, be careful with that, as it can cause some security problems on your app. Perhaps you could use Intents or other ways to make that link between your apps.
For more information on that, please refer to the documentation.
Every device running android 4.0+ is based on MTP (MEDIA TRANSFER PROTOCOL) which means that if you mount your device to the PC, it will still be available to your application, so don't worry about it too much. You must have read some outdated articles about this.
EDIT: According to the answer of CommonsWare, it's 3.0+ even, but devices running Android 3.x are so rare they are basically dead.
For lightweight primitives (strings/ints, etc), you can write to system settings, which is hard to remove by end users.
You can expose app's data by using flag Context.MODE_WORLD_READABLE.
Use ContentProvider for structed data. Use the authorities and permissions so that only your apps are allowed to read/write to content provider.
External storage, but as you said, is not reliable. The data on it are public and visible to all apps and also to end user. The data are easily deleted by users and some cleaning app.
I was wondering, when we download an app which is very cool but before you install it ask to give permission for almost everything you have on the phone. Even that app can make call without your permission to your contacts. Given this scenario, how do we say an unrooted device where app data is secured from other app access? if I have an app which stores data on the device memory then would that be accessed by one of those app which takes all permission before installed?
Thanks in advance for your response.
Apps are still sandboxed, they can't access each others internal storage even with requested permissions.
I'm not sure this is the correct forum for your question though as it's not related to developing. This isn't the right site for IT support.
Edit
As mentioned in the comments - anything put somewhere insecure location such as the SD card would be readable, but the default file storage is a bit more secure.
From the android docs (http://developer.android.com/training/basics/data-storage/files.html)
Note: Your app's internal storage directory is specified by your app's
package name in a special location of the Android file system.
Technically, another app can read your internal files if you set the
file mode to be readable. However, the other app would also need to
know your app package name and file names. Other apps cannot browse your internal directories and do not have read or write access unless you explicitly set the files to be readable or writable.
In which cases I should forbid the users to move my app to the SD Card (by setting installLocation to internalOnly)?
I'm asking to know this for a few apps, so please don't ask about my app. I want to know this in general for any app.
The requirements is quite well described in the documentation. Primarily, if you're running anything in the background that must execute at all times, like a service, or if you provide widgets, you can run from external storage. But as soon as the user unmount the external storage, the process in which these things run will be terminated.
If you define android:installLocation="auto" inside the manifest inside the AndroidManifest.xml file then and then(yes it must) it will allows user to move app to SD card option.
There are 3 values you can set to android:installLocation attribute:
android:installLocation="auto"
android:installLocation="internalOnly"
android:installLocation="preferExternal"
The Android documentation has a pretty comprehensive list about this - http://developer.android.com/guide/appendix/install-location.html
The key point is that when the user starts using the device as a USB drive, Android will kill everything related to your app. So, anything which has to run in the background to function properly or has to use the external storage should not be put on the SD card.
Have a look at this app on PS.
The service must not stop and it should run all the night. In this kind of scenarios as suggested by Peter Lillevold. We must explicitly mention android:installLocation="internalOnly"