How to align data in justify mode in a webview from sharedpreference
<p>I have one shared preference and one paragraph is storing into it. The value is properly writing to shared preference and I can read from it and its showing on to the webview;
No errors on this.</p>

<p>I used a sting declaration in XML file and aligned it in the justify mode and I am successfully displayed data.</p>

<p>My Question is how to align above text in Justify mode to a webview when I am using a string dynamically;</p>

<p><strong>Explanation to the Question</strong></p>

<p>Suppose I am getting one paragraph of data from user or I am assign a large data to the string in activity Not in the string.xml file, then how should the justify align possible;</p>

<p>Below code is that I successfully displayed data in justify mode from the string.xml file.</p>

<pre><code>public class MainActivity extends Activity {
    SharedPreferences pref;
    SharedPreferences.Editor edi;
    String prefname="Test";
    static final  String Id ="Desc";


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

             String s=getResources().getString(com.testwebviewalign.R.string.MyDesc);


       //writing to shared 
        pref=getSharedPreferences(prefname, MODE_PRIVATE);
        edi=pref.edit();
        edi.putString(Id,s );
        edi.commit();

        //reading from shared
        pref=getSharedPreferences(new MainActivity().prefname, MODE_PRIVATE);
        String D=pref.getString(new MainActivity().Id, null);


        WebView wv=(WebView)findViewById(com.testwebviewalign.R.id.webView1);
        //wv.setVerticalScrollBarEnabled(true);
        wv.loadData(D, "text/html", "utf-8");


    }

  }
</code></pre>

<p>The XML file for string declaration</p>

<pre><code>    &lt;string name="MyDesc"&gt;
       &lt;![CDATA[
        &lt;html&gt;
             &lt;body style="text-align:justify;color:black"&gt;
This valuse is for testing the alignment of the android file when using the webview, Actual thing is to convert the local text view activity in to the webview so that we can align text in justify mode. Justify mode that we can align with two sides porerly and text will display in a decen manner and well aligned format. Only with webview its posiible in native android activity. Thak you
            &lt;/body&gt;
        &lt;/html&gt;
       ]]&gt;

    &lt;/string&gt;
</code></pre>

<p>What I need is how should display data in align mode, when its not reading form the xml file suppose it is declared and initialized in code like below  </p>

<pre><code>public class MainActivity extends Activity {
    SharedPreferences pref;
    SharedPreferences.Editor edi;
    String prefname="Test";
    static final  String Id ="Desc";


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

             String s="This valuse is for testing the alignment of the android file when using the webview, Actual thing is need to convert the local text view activity in to the webview so that we can align text in justify mode. Justify mode is sthat we can align with two sides porerly and text will display in a decen manner and well aligned format. ONly with webview its posiible in native android activity. Thak you";



       //writing to shared 
        pref=getSharedPreferences(prefname, MODE_PRIVATE);
        edi=pref.edit();
        edi.putString(Id,s );
        edi.commit();

        //reading from shared
        pref=getSharedPreferences(new MainActivity().prefname, MODE_PRIVATE);
        String D=pref.getString(new MainActivity().Id, null);


        WebView wv=(WebView)findViewById(com.testwebviewalign.R.id.webView1);
        //wv.setVerticalScrollBarEnabled(true);
        wv.loadData(D, "text/html", "utf-8");


    }

  }
</code></pre>

<p>Please help, I appreciate your help;</p>
