Hello.
I want to be able to read or access the files inside the folder WhatsApp/media/WhatsApp Video
but when trying to get a list of the files in that folder, with this code, I can't.
Manifest
I run the test code in Activity_Resume
I get the following error
I want to be able to read or access the files inside the folder WhatsApp/media/WhatsApp Video
but when trying to get a list of the files in that folder, with this code, I can't.
Manifest
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
)
'to receive share
AddActivityText(Main,
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>)
AddManifestText(
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
I run the test code in Activity_Resume
B4X:
Sub Activity_Resume
Activity.LoadLayout("Layout")
Dim rp As RuntimePermissions
rp.CheckAndRequest(rp.PERMISSION_READ_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result Then
Log("What... Video: " & File.IsDirectory(File.DirRootExternal, "WhatsApp/Media/WhatsApp Video"))
Else
Log("No hay permiso de lectura")
End If
Try
Dim Archivos As List
Archivos.Initialize
Archivos = File.ListFiles(File.DirRootExternal & "WhatsApp/Media/WhatsApp Video")
Log("Size " & Archivos.Size)
Catch
Log(LastException)
End Try
Log(Archivos.Size)
End Sub
I get the following error
(RuntimeException) java.lang.RuntimeException: Object should first be initialized (List).