android-external-storage

SecurityException: Permission Denial: reading (only on emulator)

删除回忆录丶 提交于 2019-11-27 15:47:05
问题 I have two activities in my app, MainActivity calls ImagePicker, which has a GridView laying out all the images in the phone gallery, where I use a ContentResolver to get the cursor. It worked fine on my phone when I tested it but crashed every time instantly on emulator. Here's the error log: java.lang.SecurityException: Permission Denial:reading com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=5934, uid=10060 requires android.permission.READ

How app can access files on USB OTG storages in Android 6.0 (API level 23) without root?

雨燕双飞 提交于 2019-11-27 13:59:31
Android 6.0 Developer Preview (API level 23) can natively mounts external removable USB OTG storages out-of-the-box without any additional apps (for more info please see: https://www.androidpolice.com/2015/05/28/android-m-feature-spotlight-external-storage-can-be-adopted-as-true-internal-storage-or-accessed-normally-with-no-additional-apps/ ). When user connects USB OTG storage, it shows up in the system storage menu and it is accessible with the built-in file manager. User can access all files on the USB OTG external storage using the new built-in file manager without root rights. When I

Can't access the secondary storage (the external removable micro sd card)

落爺英雄遲暮 提交于 2019-11-27 08:43:43
问题 Please read my question introduction before reading the real question: In Android there are an internal storage and an external storage . Don't be confused, because the internal storage relates to files that are accessible only by the app, and the external storage relates to normal files that can be accessed by all apps and can be found both in the real internal storage card (the phone's sd card) and in the real external storage card (the removable micro sd card). My path of the phone's sd

Android: mkdirs()/mkdir() on external storage returns false

本小妞迷上赌 提交于 2019-11-27 04:25:16
问题 I'm driven crazy with this: Log.d("STATE", Environment.getExternalStorageState()); File f = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "work_data"); Log.d("PATH", f.getAbsolutePath()); if (!f.exists()) { Log.d("MAKE DIR", f.mkdirs() + ""); } The output log looks like this: STATE mounted PATH /mnt/sdcard/DCIM/work_data MAKE DIR false I made sure to add the correct permission: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Why getExternalFilesDirs() doesn't work on some devices?

帅比萌擦擦* 提交于 2019-11-27 03:27:04
问题 My app runs on Android 5.0. I use method getExternalFilesDirs() to check if external SD card is available. If it returns more than 1 File , that means external SD card exists. But on some devices (for example Elephone G2), method getExternalFilesDirs() returns only one directory of primary storage. I'm sure that device has external SD card (/storage/sdcard1/). Can any one give me the answer? 回答1: For getExternalFilesDirs to return the path of the sdcard, the OEM must have set the SECONDARY

How to get an External storage sd card size (With Mounted SD card)?

回眸只為那壹抹淺笑 提交于 2019-11-26 22:52:39
问题 Link :I worked on based on this Link I added this line to find the size (both Internal and External) size, return availableExternalMemorySize/(1024*1024); I tested in my Tablet. I am getting both Internal and External SD card size as, In Internal Storage: Total Memory --1007 Available Memory --683 In External Storage: Total Memory -- 1763 Available Memory -- 1554 But in Tablet, I saw settings. An External Storage size has 8GB. But it is showing me 1.7 GB around when I tested via

Android Open External Storage directory(sdcard) for storing file

随声附和 提交于 2019-11-26 17:19:54
I want to open external storage directory path for saving file programatically.I tried but not getting sdcard path. How can i do this?is there any solution for this?? private File path = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + ""); or private File path = new File(Environment.getExternalStorageDirectory() + ""); I tried getting path from above both methods but both are pointing internal memory. When we open storage memory if sdcard is peresent it will shows like below- device storage & sd memory card. I want to get sd memory path through coding.

Universal way to write to external SD card on Android

别等时光非礼了梦想. 提交于 2019-11-26 14:53:52
In my application, I need to store lots of images in the device storage. Such files tend to fulfill the device storage, and I want to allow users to be able to choose external SD card as the destination folder. I read everywhere that Android doesn't allow users to write to external SD card, by SD card I mean the external and mountable SD card and not the external storage , but file manager applications manage to write to External SD on all Android versions. What is the better way to grant read/write access to external SD card on different API levels (Pre-KitKat, KitKat, Lollipop+)? Update 1 I

READ_EXTERNAL_STORAGE permission for Android

假如想象 提交于 2019-11-26 12:15:13
I'm trying to access media files (music) on the users device to play them; an easy "hello world"-music player app. I've followed some tutorials and they basically give the same code. But it won't work; it keeps crashing and telling me: error..... Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/audio/media from pid=27696, uid=10059 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission() .... Now, this is my manifest file: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=

Android Open External Storage directory(sdcard) for storing file

给你一囗甜甜゛ 提交于 2019-11-26 06:05:35
问题 I want to open external storage directory path for saving file programatically.I tried but not getting sdcard path. How can i do this?is there any solution for this?? private File path = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + \"\"); or private File path = new File(Environment.getExternalStorageDirectory() + \"\"); I tried getting path from above both methods but both are pointing internal memory. When we open storage memory if sdcard is