title: Invalid value entry in Sharedpreferences
body: <p>I get user values ​​from webview via @JavascriptInterface, there is no problem with this.</p>
  
  <p>Next I record the obtained values ​​in preferences, for their further use.
  However, as Logs shows, values ​​are not written correctly. </p>
  
  <p>What am I wrong about?</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity
          implements NavigationView.OnNavigationItemSelectedListener {
  
      SharedPreferences sPref;
      public static final String PREFS_FILE = "MyPrefsFile";
  
      ................
  
      public class WebAppInterface {
          Context mContext;
  
          WebAppInterface(Context c) {
              mContext = c;
          }
  
          @JavascriptInterface
          public void showUser(String data) {
              Log.d("MyTAG", "INPUT: "+data);
              ArrayList&lt;String&gt; stringArray = new ArrayList&lt;String&gt;();
              JSONArray jsonArray;
              try {
                  jsonArray = new JSONArray(data);
                  for (int i = 0; i &lt; jsonArray.length(); i++) {
                      stringArray.add(jsonArray.getString(i));
                      Log.d("MyTAG", "i="+i+" :"+jsonArray.getString(i));
                  }
                  Log.d("MyTAG", "Array: "+stringArray);
              } catch (JSONException e) {
                  e.printStackTrace();
              }
  
              sPref = getSharedPreferences(PREFS_FILE, 0);
  
              SharedPreferences.Editor ed = sPref.edit();
              ed.putString(NAME,stringArray.get(0));
              ed.putString(AVATAR,stringArray.get(1));
              ed.putString(USER_ID, stringArray.get(2));
  
              ed.commit();
  
  
              Log.d("MyTAG", "name="+sPref.getString(NAME, ""));
              Log.d("MyTAG", "avatar="+sPref.getString(AVATAR, ""));
              Log.d("MyTAG", "user_id="+sPref.getString(USER_ID, ""));
  
          }
  
      }
  
  
  }
  </code></pre>
  
  <p>Logs:</p>
  
  <pre><code>D/MyTAG: INPUT: ["myname","src","2"]
  
  D/MyTAG: i=0 :myname
  D/MyTAG: i=1 :src
  D/MyTAG: i=2 :2
  
  D/MyTAG: Array: [myname, src, 2]
  
  D/MyTAG: name=src
  D/MyTAG: avatar=src
  D/MyTAG: user_id=2
  </code></pre>
  
  <p>For some reason, the meaning changes to the following.</p>
  
  <p>How to get preferences value <code>name = myname</code></p>