android-external-storage

Unable to create file on removeable sdcard in Android 5.0.1

时光总嘲笑我的痴心妄想 提交于 2020-01-06 15:10:22
问题 I am working on an application that needs the ability to create files on the removable sd card in the Samsung S4 i9295 device. I am running a stock Samsung ROM 5.0.1 that has been rooted. For test purposes, I have been trying to create these files by hardcoding the paths for this specific device, but have been unable to create files on the removable card. The code below creates files as expected on the internal sd card but not on the removable card. //creates directory on internal sdcard

Android: Asus Nexus 7 does not commit emulated memory until restart

亡梦爱人 提交于 2020-01-05 03:39:09
问题 I have a very specific issue - I am trying to write to external storage on an Asus Nexus 7, but it is writing to the emulated directory on the device. Here is the code I am using: public static void writeExternalMedia(Context context) { if(isExternalStorageWritable()) { String content = "hello world"; File filedir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/test"); filedir.mkdir(); File file; FileOutputStream outputStream; try { file = new

Getting the path to SD card

冷暖自知 提交于 2020-01-02 11:06:46
问题 Please read the whole post before down-voting and/or marking it as a duplicate! I'm working on an app that reads files from within a specific folder on the user's phone - either from the SD card (if there's one) or from the built in storage. Yes, the "READ_EXTERNAL_STORAGE" is mentioned in the manifest and I'm also handling the permission popup for API>23. I used to simply use File folder = new File(Environment.getExternalStorageDirectory(), "myfolder"); to get the path of the folder that is

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

北战南征 提交于 2019-12-28 04:01:27
问题 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

How to create intent activity with file pick dialog?

喜夏-厌秋 提交于 2019-12-25 04:23:18
问题 More exactly, how to create activity and then how to use selected path to write to removable storage? Like this, and this? 回答1: First you need to create Custom Dialog for Hint. then call intent to open specific Folder. see below code. Uri selectedUri = Uri.parse(Environment.getExternalStorageDirectory() + "/myFolder/"); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(selectedUri, "resource/folder"); if (intent.resolveActivityInfo(getPackageManager(), 0) != null) {

open failed: EACCES (Permission denied) from IoBridge.java in AsyncTask

允我心安 提交于 2019-12-24 16:27:25
问题 I am trying to download a file through FTP. Basically I am using two tabs fragment of an activity. RemoteTabFragment and LocalTabFragment. In LocalTabFragment, I am listing file in my Download directory. While in RemoteTabFragment, I am listing remote files and there is option to download remote file to local download directory. For FTP operations I am using AsyncTask.Here is doInBackground function of AsyncTask: protected FTPClient doInBackground(Void... args) { Log.d("siteobj", site

Failed to create directory in Android Oreo (API 26)

邮差的信 提交于 2019-12-24 04:24:11
问题 I have already read the documentation for Android Oreo's Behavior and changes. I know there is different procedure to create file directory for Android Oreo (API 26) Code : File mediaStorageDir = null; if (Build.VERSION.SDK_INT >= 26) { mediaStorageDir = new File(Environment.getExternalStorageDirectory().toString(), "MyDirectory"); Log.v("HEREEEEE","YES"); } else { mediaStorageDir = new File(Environment.getExternalStorageDirectory().toString() + File.separator + "MyDirectory"); } if (

Sdcard File not open in OS 6 and later

社会主义新天地 提交于 2019-12-24 01:58:16
问题 I have one method which open files from my app and this method running well on every OS for Internal Storage but when sdcard from OS 6 and upper want to open the file then I found an error : Failed to find the configured root that contains /storage/BE02-07BA/WhatsApp/Media/WallPaper/download (1).jpg My code is below : try { File f = new File(feedItem.getFilePath()); MimeTypeMap map = MimeTypeMap.getSingleton(); String url = f.getName(); url = URLEncoder.encode(url, "UTF-16").replace("+", "%20

android.permission.WRITE_MEDIA_STORAGE error

点点圈 提交于 2019-12-24 00:45:36
问题 I am working on an app that edits text files. I am able to r/w files when they are opened via an ACTION_OPEN_DOCUMENT activity: Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); It all works just right on both internal and external SD storage. I have also set up the app with an intent-filter for android.intent.action.VIEW. The app shows up in the "chooser" in the Android MyFiles

Distinguish SDCard URI from USBStorage URI returned by SAF or StorageVolume API

穿精又带淫゛_ 提交于 2019-12-23 03:05:07
问题 I am using StorageVolume API to retrieve URI for both SDCard and USBStorage by following StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE); for (StorageVolume storageVolume : storageManager.getStorageVolumes()) { if (!storageVolume.isPrimary()) { Intent accessIntent = storageVolume.createAccessIntent(null); startActivityForResult(accessIntent, 11); } } In onActivityResult I am able to retrieve the URI, saving it to the SharedPreferences and taking Persisting