android-storage

Not getting correct value of Storage Volume(Internal)

不羁的心 提交于 2021-02-11 13:41:30
问题 I want total internal space available in Phone but in this code getInternalFreeSpace returns correct value but getInternalStorageSpace doesn't return exact available space because of not counting ANDROID OS Size. Like my phone has 64GB but this code returns 51.6GB. The Only missing is 12.40 GB i.e. ANDROID OS size, 51.6GB + 12.40 = 64.00 fun getInternalStorageSpace(): Float{ val statsFs = StatFs(Environment.getDataDirectory().absolutePath) val sizeKB = statsFs.blockCountLong.toFloat() *

How to create folder (Android R - Api 30)?

故事扮演 提交于 2021-01-01 10:23:12
问题 Read that Android 11 has scoped storage, but I can't find any information, how can I create and use folder in /storage/emulated/0/ ? Old methods works only on api 29 and below :( 回答1: On Android 11 the restrictions in Android 10 concerning access to external storage are much less. Environment.getExternalStorageDirectory() is readable again and Environment.getExternalStoragePublicDirectory(...) is writable for folders like Environment.DIRECTORY_DOCUMENTS and so on. The Android OS is very picky

How to create folder (Android R - Api 30)?

限于喜欢 提交于 2021-01-01 10:23:06
问题 Read that Android 11 has scoped storage, but I can't find any information, how can I create and use folder in /storage/emulated/0/ ? Old methods works only on api 29 and below :( 回答1: On Android 11 the restrictions in Android 10 concerning access to external storage are much less. Environment.getExternalStorageDirectory() is readable again and Environment.getExternalStoragePublicDirectory(...) is writable for folders like Environment.DIRECTORY_DOCUMENTS and so on. The Android OS is very picky

Unable to access storage in Android Q

风格不统一 提交于 2020-03-03 05:47:04
问题 Although having read and write permissions I am unable to access sdcard in Android 10. This was my approach to list all directory. File root = new File("/mnt/sdcard/"); File[] subFiles = root.listFiles(); for(File file : subFiles) { if(file.isDirectory()) { String str = text.getText().toString() + "\n"; str+=file.getAbsolutePath(); text.setText(str); } } If I use /mnt/ instead of /mnt/sdcard/ I can see sdcard directory is listed in there but when I use /mnt/sdcard/ , subFiles is null . I don