I need some help with granting write permissions to external sd card on an Android TV box (Xiaomi Mi Box).
I plugged a micro SD card using a USB adapter and I can access the files and read them without any problem. I can even write to an app specific folder located at Android\data\app package name.
However, When I try to write files to the root directory of the sd card I'm asked to Grant permission to the app. On a normal Android phone a different app bulit in inside of Android will be opened, where there I will select the sd card and then and give the app a permissions for writing to it. However, this app doesn't exists on the Mi Box.
I side loaded the app to the streamer (it's called my files),and it was installed successfully, but it didn't show me the sd card I plugged in what so ever, so I couldn't give the app a write permissions.
So my question is: is there an alternative way to grant an app a write permissions to an extenal SD card? Maybe through adb?
If someone knows about any solution it would be really helpful.
If your solution doesn't involve rooting it would be wonderful.
Thank you and have a great day!
Related
Now, I am working on data transmission using bluetooth. I have such problem in selecting file in SD card/ internal storage.
I am already put permission in manifest :
I am using this command to get access the file
File sdCard = Environment.getExternalStorageDirectory();
But when I am check using this command if (sdCard.canRead()) , it can't read the path.
Anyone have the solution within my problem? Thanks anyway
The Android Dev resources has a good guide on this.
Assuming you have all the correct permissions, you could be facing issues where the storage is not mounted or there is not enough space. The guide explains how to check the state of the External Storage Dir, etc.
Did you add the following line to the AndroidManifest?
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
From android SDK version 4, you need to add that line to access external storage by your app.
Some of other issues are, (Check whether phone detects the SD card)
SD Card is Not Clean
Battery Voltage
Card Slot is Squeezed
Metal Wires in the Card Slot Get Rusty and Twisted
Malware Invade SD Card
SD Card is not Formatted Properly
SD Card is Broken
The Phone Breakdown
problem solved.
The problem is related with new android SDK. We need to add additional permission.
Thanks everyone.
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.
I have an app on Google Play market and I added android:installLocation="preferExternal" to manifest.xml file and released long time ago. Now I would like to add Android home screen widget, so I need to change it to android:installLocation="internalOnly". If I do that, what happens when a user upgrades? because a user already installed the old app on SD card. What is the best solution for this situation??
If someone has this kind of experience, please advise me.
Thanks in advance :)
When you set install location to preferExternal the application specific files are stored in .android_secure directory in external sdcard.
These type of application are not available when user mounts the SD Card as USB Mass Storage (feature removed from Android Jelly Bean).
Coming to the question, I believe in your case the application would be installed onto internal memory with the files from .android_secure moved to internal location.
You can confirm this by the following:
Install the application from play store having install Location as preferExternal.
Confirm that your application is installed in external SD card, you can use Settings->App to check that.
Now create your new signed application package.
Install using adb install -r myapp.apk
Again goto Settings->App and confirm the location.
Run functional test to see if nothing is broken.
Old question, but according to my test, if an app is installed on SD card and you change afterwards the Manifest to android:installLocation="internalOnly" (or omit the android:installLocation attribute, which is the same), when the app is upgraded the package manager will automatically move the app from SD Card to internal storage.
No idea what happens if this is not possible (not enough root on internal storage for example).
My code logic needs an SD card installed in the device. I have added a check for this case in the application's splash screen, but would like to inform users before they download/install this app. Is there a way to achieve this ?
Thanks !
There is no way to do this before the app installs, as the only way to limit such things is by using the <uses-feature> tag. However, that tag has no options for storage requirements. The best warning you can give is to prominently include it in your app description.
On the other hand, every device I've ever heard of an encountered has some form of external storage, be it a SD Card or inbuilt memory mounted as external storage. What you're doing by using the Splash Screen to check for the external storage is the best way to do this, as there is no other option.
There's no way to do that. Your app have to be installed to be able to check user's environment. You could try to to enforce SD card installation of your app, so if there's none Google Play might (not tested) simply not allow app installation at all, but it will not solve your problem as user will still do not know why. Solution is to clearly state in product description that SD card is mandatory. But note, that requiring SD card is risky as many devices does not have any while still offer external storage. My suggestion - just add note about storage requirements and let system deal with it.
I think it is NOT POSSIBLE . You are checking the sdcard on splash screen and prevent user for next process is the right solution or Use android:installLocation for install android application on sdcard.
Beginning with API Level 8, you can allow your application to be
installed on the external storage (for example, the device's SD card).
This is an optional feature you can declare for your application with
the android:installLocation manifest attribute.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="preferExternal"
... >
If you declare "preferExternal", you request that your application be
installed on the external storage, but the system does not guarantee
that your application will be installed on the external storage. If
the external storage is full, the system will install it on the
internal storage. The user can also move your application between the
two locations.
When your application is installed on the external storage:
There is no effect on the application performance so long as the
external storage is mounted on the device.
The .apk file is saved on the external storage, but all private user
data, databases, optimized .dex files, and extracted native code are
saved on the internal device memory.
The unique container in which your application is stored is encrypted
with a randomly generated key that can be decrypted only by the
device that originally installed it. Thus, an application installed
on an SD card works for only one device.
The user can move your application to the internal storage through
the system settings.
Look Here for more details .
I just want to view the files(especially the .png files) associated with one of the application in my mobile. The application is actually installed(moved) in the SD card.
The issue is ..I could not find the application in the SD card. I am using a file browser called 'File Manager' to browse through the SD card. Can someone help me on this.
It should be here:
/mnt/sdcard/Android/data/your_package_name/
Some hardware implements the path to the external storage different.
/mnt/sdcard/Android/data/your_package_name/
/mnt/sdcard-ext/Android/data/your_package_name/
You may be able to get a better view of what is on the device by using the ADB Shell. If you still have trouble at this point trying running grep or find from the shell.
UPDATE
Most of the time the files associates with your application are in the directory with your application. The application is installed in /data/data/your.package.name/. However you will need root access to get here if you are on a phone, I think the emulator lets you get here. As far as external storage... yea its a pain, to much fragmentation in the market. You have to programmatically check the location of the external storage.
On my device with Android 2.3.6 apps moved on the SD card are located into a directory named .android_secure as .asec files (see http://www.fileinfo.com/extension/asec).
They are not visible from the standard "Archive" browser which shows the hidden directory as empty.
The files are also encrypted so I guess no access to the images within is possible.