in my app the classe ExternalStorage is used to store files in the SD card.
This also works quite well. But now it happens that the user removes the SD card and no longer thinks about it.
Since now when saving the SD card is no longer that and of course the storage folder is also no longer present, the app crashes.
Question: how can you intercept this error best? Or how has someone already solved it?
Hi All This or something similar has been asked many times but things have been changing quickly. The Q&A that I could find, all ended up in internal memory or secondary memory. What is the best current method to determine if a physical SD Card is fitted to the device? IE: If...
My app is working for mobiles which have an SD card only. So programmatically I want to check if the SD card is available or not and how to find the SD card free space. Is it possible? If yes, how...
I have created a function and added in the classe "ExternalStorage", so I can easily check if the storage folder exists or not.
If the storage folder does not exist anymore, it will ask to choose a new storage folder.
According to my tests seems to work.
B4X:
Public Sub IsStorageFolderSelected As Boolean
If PersistantUri.Length > 0 Then
Root = DocumentFileToExternalFile(GetPickedDir(PersistantUri))
Log("Root.Length=" & Root.Length)
End If
Return File.Exists(File.DirInternal, PreviousUriFileName) And (Root.Length > 0)
End Sub
End Sub
Whether the SD card is present is not so important in my case, what is important is whether the storage folder is present.
The storage folder can be on a SD card or in File.DirRootexternal.
If the storage folder is no longer present, then Root.Length = 0.