Android Question Android 30 Storage Permision

khwarizmi

Active Member
Licensed User
Longtime User
Hi all

I tried to run an local web page across the webview in an Android 30 device, this did not work because access is not allowed (this appeared in the webview itself)

B4X:
webView.LoadUrl("file://" & File.Combine(File.DirInternal, "/data/web/myWebPage.html"))

I added storage permission to the manifest:
B4X:
AddManifestText(
<uses-permission
  android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  android:maxSdkVersion="19" />
)

I also tried to use RuntimePermissions:

B4X:
Dim rp As RuntimePermissions
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)

NOTE: All files such as images and text files can be run, the problem only on the web page.

Thanks.
 

Ivica Golubovic

Active Member
Licensed User
I will recommend you the simplest solution. Download the UltimateWebView Custom View library from the link below.
Remove the WebView object from your Activity and add UltimateWebView via the designer (AddView-CustomView-UltimateWebView). Then add a line to Activity_Create:
Example::
UltimateWebView1.Settings.AllowFileAccess=True 'This property is set to FALSE by default in SDK30. On SDK29 and below is set to TRUE by default.
Then add the following line in the part of the code where you want to open the HTML file:
Example::
UltimateWebView1.LoadFileFromDirInternal("data/web/myWebPage.html")
The library will do the complete work for you.
One more thing, PERMISSION_WRITE_EXTERNAL_STORAGE has no effect on SDK29 and SDK30. Leave it only if you want to use the application on devices below SDK29.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…