android-external-storage

Can't create a directory on /storage/emulated/0 on emulator

陌路散爱 提交于 2019-11-29 13:46:22
I'm trying to create a directory on my android emulator but I can't do it, I already have the permission on manifest write_storage, and I get no erros but mkdir() return false, I verify if external storage is writtable too and it is, it works on physical devices my code: /// Cria uma nova pasta para colocar o backup File direct = new File(Environment.getExternalStorageDirectory(), "/Financas RW Backup"); try { if (!direct.exists()) { if(isExternalStorageWritable()&&isExternalStorageReadable()) { if( direct.mkdir()) { fachada.showMessage(ExportImportDB.this," Criado"); }else{ fachada

Access external storage in File Chooser

一笑奈何 提交于 2019-11-29 12:01:05
I am trying to implement a File Chooser. I am using Android File Explore for file chooser in my app. When I run the app, it shows me Internal storage and returns me the file path, but it doesn't show External Storage at all. This is my AndroidManifest.xml file. <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unicloud.mittal" > <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.USE_CREDENTIALS" /

Android write files to USB via OTG cable

血红的双手。 提交于 2019-11-29 05:19:48
I've been searching for many topics about android file writing, yet most of them wanted to write files to android internal storage. Others who wanted to write files on external SD card didn't success at all. My case is quite similar but I think that writing files to external USB is a totally different case. I am using Samsung galaxy Note II running stock TouchWiz 4.4.2 [not rooted]. My phone supports micro-USB-OTG and I can mount my USB as rwxrwx--x without rooting. The complete path of my USB is /storage/UsbDriveA. I've tried to use Environment.getExternalStorageDirectory() to get the path or

SecurityException: Permission Denial: reading (only on emulator)

核能气质少年 提交于 2019-11-29 01:19:12
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_EXTERNAL_STORAGE, or grantUriPermission() I do have permission written in manifest, as shown below: <uses

How does storage access change on Android 6?

不问归期 提交于 2019-11-28 16:04:53
Background Android had a lot of changes as to how to handle the SD-card and storage in general: API 3 - you get all access, no permission needed API 4-15 - you need to use WRITE_EXTERNAL_STORAGE, and you get all access. API 16-18 - if you wish only to read, use READ_EXTERNAL_STORAGE API 19-20 - you can't read or write to secondary external storage (SD-card), unless your app is a system app, or you have root. API 21-22 - in order to access the SD-card, you need to ask the user for permission, and use the DocumentFile API instead of the File API. This raied a lot of questions, as I've written

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

左心房为你撑大大i 提交于 2019-11-28 14:46:50
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 card (the one that you can't remove) is: /storage/emulated/0 . My path of the micro sd card (the one that

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

喜你入骨 提交于 2019-11-28 10:07:37
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? For getExternalFilesDirs to return the path of the sdcard, the OEM must have set the SECONDARY_STORAGE environment variable in the device specific init.rc file as mentioned here: https://source.android.com

Can't create a directory on /storage/emulated/0 on emulator

和自甴很熟 提交于 2019-11-28 07:20:50
问题 I'm trying to create a directory on my android emulator but I can't do it, I already have the permission on manifest write_storage, and I get no erros but mkdir() return false, I verify if external storage is writtable too and it is, it works on physical devices my code: /// Cria uma nova pasta para colocar o backup File direct = new File(Environment.getExternalStorageDirectory(), "/Financas RW Backup"); try { if (!direct.exists()) { if(isExternalStorageWritable()&&isExternalStorageReadable()

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

本小妞迷上赌 提交于 2019-11-27 20:03:14
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"/> But I don't know why it could not create the folder. I also used mkdir() step by step but the result is

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

做~自己de王妃 提交于 2019-11-27 19:53:57
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 programmatically. What is the procedure to find an External storage size? To get the external SD card's available