Android Question USB unmount intent - ACTION_MEMORY_CARD_SETTINGS

QtechLab

Active Member
Licensed User
Longtime User
Hi,

In my new Android App i have to unmount usb stick after writing a file on it. I just have to write a few bytes.
I found that if i remove the usb without unmoun function the file written will be empty (can this be caused by usb itself or the usb filesystem?).

I write the file with the ExternalStorage & ExternalFile procedures with outputstream.

B4X:
Dim out() As Byte = bc.StringToBytes(record, "UTF-8")
Dim output As OutputStream = storage.OpenOutputStream(rFile)
output.WriteBytes(out, 0, out.Length)
output.Flush
output.Close

So, after a long desperate search on the web i found that the only way to do an unmount is by using the android settings app.

I know that i need and intent to do that, but how can i compose that?

I try this code but it doesn't work.

B4X:
public Sub UnmountDrives()
    Dim usbintent As Intent
    usbintent.Initialize("android.provider.Settings.ACTION_MEMORY_CARD_SETTINGS", "")
    StartActivity(usbintent)
End Sub

Thanks in advance for your time.
 

drgottjr

Expert
Licensed User
Longtime User
try it this way: "android.settings.MEMORY_CARD_SETTINGS"
 
Upvote 0
Top