android-external-storage

Android 4.4.2 not deleting files

我是研究僧i 提交于 2019-12-06 07:54:46
I have a peice of code that scans for all files in a directory and it should delete those files. But for some reason it's not deleting them. What I have is this: String path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/Images/"; File f = new File(path); File file[] = f.listFiles(); for (File aFile : file) { boolean isDeleted = aFile.delete(); if(isDeleted) { log.d("file", "is deleted"); } } When I debug this code then it says for every file that isDeleted is true . But when I check the "Gallery/Images" folder on my phone I see that all images are still there... I also have

Android APIv29 FileNotFoundException EACCES (Permission denied)

微笑、不失礼 提交于 2019-12-06 06:33:13
问题 I'm not able to access storage when building for targetSdkVersion v29. Here is my gradle configuration: compileSdkVersion 29 buildToolsVersion "29.0.2" ... minSdkVersion 15 targetSdkVersion 29 NOTE that WRITE_EXTERNAL_STORAGE permission is granted and the same setup works fine when building for targetSdkVersion 28 . Here is my implementation: val outputFolder = File(baseFolder + File.separator + "Output Folder") if (!outputFolder.exists()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)

Android - How to use new Storage Access Framework to copy files to external sd card

拟墨画扇 提交于 2019-12-06 04:06:07
问题 I'm implementing a file browser feature in my app. I know how to gain persistent permission for the external sd card using the ACTION_OPEN_DOCUMENT_TREE intent and how to create folders and delete files/folders using the DocumentFile class. I can't however find a way to copy/move a file to an external sd card folder. Can you point me to the right direction ? 回答1: I have figured it out using lots of examples on SO. My solution for music files: private String copyFile(String inputPath, String

android java.io.File.fixSlashes(File.java:185)

徘徊边缘 提交于 2019-12-05 23:50:12
问题 I got an error in console crashes & anrs. This error is showing sometimes and I couldn't find where the problem is. java.lang.NullPointerException at java.io.File.fixSlashes(File.java:185) at java.io.File.<init>(File.java:134) The function code to save picture is: public static String sharePhoto(Context context, Bitmap bmp) { File folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Folder"); boolean success = true; String file_path = null; if (!folder

Recommended path for caching images on external memory / sd card

情到浓时终转凉″ 提交于 2019-12-05 20:47:18
When I look at my sd card root directory in Android file transfer or Astro file manager it's a mess because apps are storing files all over the place. As developers we follow best practice by caching images/files etc to make our apps quicker and we use Environment.getExternalStorageDirectory() to get the root of the external storage (not hardcoding /sdcard). But what should go next? ideal world we'd follow a convention for dumping our cached files on the open field that is the external storage? Here's a couple of the options I see from my own device/experience: /.cache/app_name/ /.app_name/

NPE on Environment.getExternalStorageState()?

馋奶兔 提交于 2019-12-04 22:39:40
Cannot find the reason why I am getting "Null pointer exception" . I could give an explicit check to see if "getStorageState is null" but that doesnt explain why I am getting this error. The error is : java.lang.NullPointerException at android.os.Environment.getStorageState(Environment.java:719) at android.os.Environment.getExternalStorageState(Environment.java:694) at com.ciqual.android.insight.sessionService.RemoveFiles(SessionService.java:664) com.vyshas.android.sessionService.onEndSession(SessionService.java:460) at : (the line that error points to is this :)(seen in jellybean 4.3 and

Android APIv29 FileNotFoundException EACCES (Permission denied)

99封情书 提交于 2019-12-04 15:50:19
I'm not able to access storage when building for targetSdkVersion v29. Here is my gradle configuration: compileSdkVersion 29 buildToolsVersion "29.0.2" ... minSdkVersion 15 targetSdkVersion 29 NOTE that WRITE_EXTERNAL_STORAGE permission is granted and the same setup works fine when building for targetSdkVersion 28 . Here is my implementation: val outputFolder = File(baseFolder + File.separator + "Output Folder") if (!outputFolder.exists()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { Files.createDirectory(outputFolder.toPath()) //This allways returns false with targetSdkVersion 29 }

Android - How to use new Storage Access Framework to copy files to external sd card

梦想的初衷 提交于 2019-12-04 12:35:18
I'm implementing a file browser feature in my app. I know how to gain persistent permission for the external sd card using the ACTION_OPEN_DOCUMENT_TREE intent and how to create folders and delete files/folders using the DocumentFile class. I can't however find a way to copy/move a file to an external sd card folder. Can you point me to the right direction ? I have figured it out using lots of examples on SO. My solution for music files: private String copyFile(String inputPath, String inputFile, Uri treeUri) { InputStream in = null; OutputStream out = null; String error = null; DocumentFile

External Storage Path (SD card) for Android 5.1.1 and later with Cordova

谁都会走 提交于 2019-12-04 12:27:02
I am working to develop an android APP with cordova,I wanted to create an folder everyday and store a txt file in it. everything I tried is working for the internal memory of each android but not for the External SD card, have a look and help me out, if(sDeviceVersion=='4.0' || sDeviceVersion=='4.0.4'){ var sPath = 'file:///storage/extSdCard/'; }else if(sDeviceVersion=='4.1' || sDeviceVersion=='4.1.2' ||sDeviceVersion=='4.3.1'){ var sPath = 'file:///storage/extSdCard/'; }else if(sDeviceVersion=='4.4' || sDeviceVersion=='4.4.4'){ var sPath = 'file:///storage/extSdCard/'; }else if(sDeviceVersion

android java.io.File.fixSlashes(File.java:185)

风流意气都作罢 提交于 2019-12-04 04:06:22
I got an error in console crashes & anrs. This error is showing sometimes and I couldn't find where the problem is. java.lang.NullPointerException at java.io.File.fixSlashes(File.java:185) at java.io.File.<init>(File.java:134) The function code to save picture is: public static String sharePhoto(Context context, Bitmap bmp) { File folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Folder"); boolean success = true; String file_path = null; if (!folder.exists()) { success = folder.mkdir(); } if (success) { file_path = folder + "/Img_" + System