I have a pretty basic code for a webview app: package com.budget.noname.budget; import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.webkit.WebSettings;import android.webkit.WebView; public class MainActivity extends AppCompatActivity {
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String data = "<p id='v'></p><script>x=3; y=5; m=0; document.getElementById('v').innerHTML = m;</script>"; WebView simpleWebView=(WebView) findViewById(R.id.simpleWebView); WebSettings webSettings = simpleWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setAllowContentAccess(true); webSettings.setAllowFileAccess(true); webSettings.setDomStorageEnabled(true); //simpleWebView.loadUrl("file:///android_asset/index.htm"); simpleWebView.loadDataWithBaseURL(null, data, "text/html", "UTF-8", ""); }} If I put my webapp (index.htm) in the assets folder and load it, it works perfectly, but my code is available for anyone who cares to extract the .apk. I was trying to paste the code on a String and the load it with loadDataWithBaseURL. It worked almost as well. The thing is: if I try to access the localStorage, the code breaks. Why is that? Example: String data = "<script>x=localStorage.getItem('name');</script>"; Doesn't work!!! Although, as I said, if I load the same code from the assets folder, it works. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/9295d059-d5f8-4263-b4c6-3a28b57321c5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.