Android Question Webview vs local storage (SOLVED)

jcesar

Active Member
Licensed User
Longtime User
Hi !

I'm using a webview to encapsulate an application created with react but it crashes when I try to access the local storage.

Is any type of permission required to access the local storage ?

Regards
 

DonManfred

Expert
Licensed User
Longtime User
Hiding the full error and full code is a good way not to get useful answers/help

Best is to upload a small project showing the problem.
 
Last edited:
Upvote 0

jcesar

Active Member
Licensed User
Longtime User
Hiding the full error and full code is a good way not to get useful answers/help

Best is to upload a small project showing the problem.
This is the code:

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private xui As XUI
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private WebView1 As WebView
    
    Dim IME As IME
End Sub

Sub Activity_Create(FirstTime As Boolean)
    SetStatusBarColor(0xFF000000)
    SetNavigationBarColor(0xFF000000)
    '#f6a426
    IME.Initialize("IME")
    IME.AddHeightChangedEvent
    WebView1.Initialize("wv")
    Activity.LoadLayout("Layout")
    WebView1.LoadUrl("https://delivroo.netlify.app/nocapricholanches")
    
End Sub
 
Upvote 0

jcesar

Active Member
Licensed User
Longtime User
Solved !

I use WebViewExtras and WebSettings to enable the local storage.

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private WebView1 As WebView
    Private wve As WebViewExtras
    Private wvs As WebSettings
    Dim IME As IME
End Sub

Sub Activity_Create(FirstTime As Boolean)
    
    SetStatusBarColor(0xFF000000)
    SetNavigationBarColor(0xFF000000)
    IME.Initialize("IME")
    IME.AddHeightChangedEvent
    Activity.LoadLayout("Layout")
    wve.Initialize(WebView1)
    wvs = wve.GetSettings
    wvs.SetDOMStorageEnabled(True)
    WebView1.LoadUrl("https://delivroo.netlify.app/nocapricholanches")
    
End Sub
 
Upvote 0
Top