External Storage Write Access for Kitkat devices - android

The Problem
My app supports 4.0+ and it is all about file handling. It works perfectly in all Android versions except Kitkat.
In Kitkat, my app is unable to modify or write any files in SD card. But I see various apps like,
1) Solid Explorer
2) ES File Explorer
3) CamScanner
4) UC Browser
All of these apps give write access to SD card even in Kitkat devices without even root access.
Requirements
I need to have a fully functional way to create or modify files stored in the SD card in Kitkat. I seems to have troubles a lot of users and a proper solution will help many developers like me.

Yeah I came across that problem as well. After a lot of reading across the web the solution is to write only in your app folder (Ex: /sdcard/Android/data/packagename).
About those apps, on my s4 mini, es explorer cannot delete from external sdcard, so I think is different from device to device.
If the devices is routed change the permissions to gain write access anywhere on the sdcard.

Related

Can create Files but not Directories on external storage

I've got an application which writes large files to an external USB drive. The directory to write these files to comes from context.getExternalMediaDirs(), so it normally ends up being something like /storage/<UUID>/Android/media/com.app.package/.
My problem is that on all devices I've tested so far, this works. However, on a Sony Bravia TV (running Android 8.0) I am able to create files in the external media directory, but if I call mkdirs() to create a directory it always returns false.
My application targets API 28, declares the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions, and requests them both from the user at runtime.
It also seems that this problem goes away if I allow the Sony TV to "format the device as external storage", however this formats it to FAT32 which imposes file size limits that are unacceptable for my application.
Formatting the drive to NTFS via a PC allows files to be created, but not directories.
I suspect this is indicative of a bug in Sony's implementation, but I'd like some feedback from the community.
Has anyone encountered this on other devices? Is there a potential work around?
It doesn't make sense to me that I'd be allowed to create a file, but not a directory.

Android not enough storage memory

I created an Android app sometime ago. What the app does is basically download a list of files (images and videos) and play them in a loop (like a Playlist).
These files are saved in the default Android External Storage Directory. I get it using this method:
Environment.getExternalStorageDirectory().getAbsolutePath();
Until now I never had storage problems but testing the app on an old device (which has less storage capacity) I realised that I have a problem when the files (PlayList) size is bigger than the device storage capacity.
I have thought (and research) about using an USB stick, but I don't think that would be a good solution since I cannot know 100% sure the USB path (it can be different for each device).
Any ideas about how handle this problem? Maybe another solution instead of using the USB ?
Here is what I have researched:
How to access USB Path in android?
How to find USB storage path programmatically?
android How to write files to a usb memory?
Do you need to store the actual images and videos on the device - why not just store their location and get them dynamically. I've not used a recyclerView but I thought that it could do something like this, but could be wrong.

Android app on Chromebook to access USB devices?

I am taking an Android app and making it run on Chrome using the ARC Welder. For best results we're only targeting the Chromebook / Chrome OS, not Windows or OSX.
The app is running with some minor glitches, but I need to enumerate photos on an inserted SD card.
The problem is that the /mnt folder accessible within Android Runtime only contains the virual sdcard folder, and does not reflect the real SD Card or USB Flash Drives attached to the Chromebook.
How can these photos be automatically loaded from the SD Card into the Android App in the Android Runtime.
I know that I could use a CRX (Chrome Extension) to read the SD Card photos, but how could they be passed to the Android app? And can this be in the same CRX as the ARC Welder creates or must it be a separate CRX?
I found a workaround which is to use the Additional Metadata section and add
{ "enableExternalDirectory": true }.
When the app first launches, it prompts the user for the folder. One must select the SD card.
Then my app works as expected, as the 'emulated sd card' becomes the 'real sd card'. This is not the most user-friendly approach, but it works.
I'd still prefer if we could load the files from a CRX into the Android Runtime...

4.4 Real External SDCard in Emulator

If I'm not wrong android no more allows 3rd party apps to write inside real external SD card since Honeycomb(except own data folder provided by OS) ? But no hardware manufacture followed that in their devices. But now Samsung and LG seems to be using it from 4.4 (API 19) and because of that I'm receiving bug reports of permission denied. Or maybe Im wrong about honeycomb.
Since I need to test my app, I'm unable to create an emulator using real external SD Card. I mean the SD Card I created is emulated by device. Which android allows for all apps. Is there any way I can create something that emulator treat it as real external card ?

SDCard content exist but cant see them

I am having very Strange problem with my Samsung Nexus with Android 4.0.2. I wrote a simple program which basically create file each time user presses a button. My program is working great on other devices where as on Galaxy Nexus Windows/Mac can not see those files on SD card, but when i do adb shell i see all files on SD Card.
I retest this on another Nexus which has Android 4.0.4 but still same result.
What could be the reason?
You probably need to index your files via MediaScannerConnection. Quoting myself from a blog post from last year:
...the MTP contents are not based on the literal contents of external storage. Instead, MTP contents are based on what files have been scanned by MediaScannerConnection. If you write a file to external storage, until and unless that file is scanned by MediaScannerConnection, it will not be visible to users over MTP.
External storage is scanned on a reboot and possibly on a periodic basis. Users can manually force a scan via utilities like SDRescan. However, the best answer is for you to use scanFile() on MediaScannerConnection to update the media database after you close your file. This will make your file immediately available to the user.

Categories

Resources