How do I write data to the SD card in Android via a StorageVolume?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How do I write data to the SD card in Android via a StorageVolume?



I am desperately trying to write data to the SD card with my app. I am attempting to use the StorageVolume class to do this, but I am having lots of trouble.



This is what I have:


StorageManager storageManager = (StorageManager)context.getSystemService(STORAGE_SERVICE);
List<StorageVolume> storageVolumeList = storageManager.getStorageVolumes();
for(StorageVolume volume : storageVolumeList)
if(volume.getDescription(context).equalsIgnoreCase("sd card"))
Intent write_to_sd_card_intent = volume.createAccessIntent(Environment.DIRECTORY_DOCUMENTS);
if(write_to_sd_card_intent != null)

context.startActivityForResult(write_to_sd_card_intent, Constants.WRITE_TO_SD_CARD_REQUEST_CODE);





When I do this, it does ask my permission to write to that location, which is good, but I don't know what to do next. I looked at this article, but it doesn't say what to do after the startActivityForResult().


startActivityForResult()



I don't believe I can use the same procedures for a normal intent, as volume.createAccessIntent() creates an intent differently than a "normal" intent, because you are not passing the next activity into the method parameter.


volume.createAccessIntent()



Also, I don't see a way to use a StorageVolume to get a path to write my data to.


StorageVolume



Any suggestions?



As an FYI, I have tried all of the Android approved methods of writing to the SD card with no luck. See my previous post HERE





FYI, an Intent on Android is just an abstract description of an operation to be performed. It can sure be used to start another Activity but it's far from its sole purpose.
– shkschneider
Aug 8 at 13:39


Intent


Activity





@shkschneider I don't know what you are trying to tell me.
– Brian
Aug 8 at 13:59





I'm just noticing, regarding your comment about a "normal intent", that an Intent has many more usages behind starting an Activity. The italic part was from Google ^^
– shkschneider
Aug 8 at 14:04


Activity





@shkschneider I meant "normal" as in the way the Intent is created.
– Brian
Aug 8 at 14:08


Intent









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard