android-storage

Read/Write Removable SD Card (android emulator)

与世无争的帅哥 提交于 2019-12-14 02:20:25
问题 Every time I try to read the informations of SD Card (removable storage), I get android.system.ErrnoException: statvfs failed: EACCES (Permission denied) I added permissions in manifest file : <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> As minSdkVersion > 23 public static void verifyStoragePermissions(Activity activity) { // Check if we have write permission int permission =

Cannot Find Image Stored

自古美人都是妖i 提交于 2019-12-11 15:16:38
问题 I am currently using this code to store images (it might be wrong). The path is this: public static final String IMAGE_DIR = "test"; The code for saving the image is as follow: public class ImageSaver { private String directoryName = Constants.IMAGE_DIR; private String fileName = ""; private Context context; private boolean external; public ImageSaver(Context context) { this.context = context; } public ImageSaver setFileName(String fileName) { this.fileName = fileName; return this; } public

Writing EXIF data to image saved with DocumentFile class

与世无争的帅哥 提交于 2019-12-08 01:52:58
问题 I need to get a File from DocumentFile or Uri with correct scheme not the one with content://com.android.externalstorage.documents/tree/primary: if the device's main memory is selected. To get File or absolute path of the image i need the one with file:///storage/emulated/0 or storage/emulated/0 but i could not find a way to get correct Uri for building a File to write EXIF data to image. My scenario is: User chooses a path to save images which returns Uri with content://com.android

Writing EXIF data to image saved with DocumentFile class

只愿长相守 提交于 2019-12-06 07:27:25
I need to get a File from DocumentFile or Uri with correct scheme not the one with content://com.android.externalstorage.documents/tree/primary: if the device's main memory is selected. To get File or absolute path of the image i need the one with file:///storage/emulated/0 or storage/emulated/0 but i could not find a way to get correct Uri for building a File to write EXIF data to image. My scenario is: User chooses a path to save images which returns Uri with content://com.android.externalstorage.documents onActivityResult(). I save this path with treeUri.toString() to SharedPreferences for

Delete folder from internal storage in android?

谁都会走 提交于 2019-12-03 11:21:39
问题 How to delete folder(contain some folder and file) from internal storage? Folder have some below tree. folder |_________ C2 (folder) |________1 (folder) |________1.gif |________2.gif |________3.gif |________4.gif |________2 (folder) |________1.gif |________2.gif |________3.gif |________4.gif |________3 (folder) |________1.gif |________2.gif |________3.gif |________4.gif |________4 (folder) |________1.gif |________2.gif |________3.gif |________4.gif |________5 (folder) |________1.gif |_______

Delete folder from internal storage in android?

北慕城南 提交于 2019-12-03 01:55:59
How to delete folder(contain some folder and file) from internal storage? Folder have some below tree. folder |_________ C2 (folder) |________1 (folder) |________1.gif |________2.gif |________3.gif |________4.gif |________2 (folder) |________1.gif |________2.gif |________3.gif |________4.gif |________3 (folder) |________1.gif |________2.gif |________3.gif |________4.gif |________4 (folder) |________1.gif |________2.gif |________3.gif |________4.gif |________5 (folder) |________1.gif |________2.gif |________3.gif |________4.gif |_________ C2.xml (file) I want to delete folder and containing all

Unable to write files in Android P

不羁岁月 提交于 2019-12-02 02:26:25
问题 I couldn’t write files in Android P Memory Card. The same code is working fine in Android O. new File(file.getParent()).mkdirs(); output = new ObjectOutputStream(new FileOutputStream(file)); output.writeObject(obj); I am able to read the files from the same device(Memory Card), but when I try to write the file, it is throwing Permission Denied exception. Initially it was throwing me No such file or Directory , but after giving root permissions, it is throwing Permission Deniod exception. Note

Unable to write files in Android P

谁说胖子不能爱 提交于 2019-12-01 22:26:10
I couldn’t write files in Android P Memory Card. The same code is working fine in Android O. new File(file.getParent()).mkdirs(); output = new ObjectOutputStream(new FileOutputStream(file)); output.writeObject(obj); I am able to read the files from the same device(Memory Card), but when I try to write the file, it is throwing Permission Denied exception. Initially it was throwing me No such file or Directory , but after giving root permissions, it is throwing Permission Deniod exception. Note: My app is system privileged app and also I have given the Devicewith root permission by adb root,

Android PackageStats gives always zero

此生再无相见时 提交于 2019-11-30 16:06:57
I'm trying to get the size occupied by my application package. Every application has one location in the internal/external storage. I want to calculate the size of the following directory, how can I do that? I know I can use StorageStateManager on and above Oreo (API 26) devices, but how can I achieve this before oreo devices. Application Directory : /Android/data/myapplicationpackage I'm trying to use PackageStats but It's giving me always zero. What's the actual way to use this code? I used the following code and it gives me all zero. PackageStats stats = new PackageStats(context

Android PackageStats gives always zero

耗尽温柔 提交于 2019-11-29 22:17:45
问题 I'm trying to get the size occupied by my application package. Every application has one location in the internal/external storage. I want to calculate the size of the following directory, how can I do that? I know I can use StorageStateManager on and above Oreo (API 26) devices, but how can I achieve this before oreo devices. Application Directory : /Android/data/myapplicationpackage I'm trying to use PackageStats but It's giving me always zero. What's the actual way to use this code? I used