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 {

    protected void onCreate(Bundle savedInstanceState) {
        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();
        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 

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?


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 
For more options, visit https://groups.google.com/d/optout.

Reply via email to