title: Best practice to implement key-value pair in android Spinner
body: <p>I want to implement an android spinner with key value . </p>
  
  <blockquote>
    <p>en:english   jp:japanese</p>
  </blockquote>
  
  <p>And when user select and item I want to save key to database . And also on next load I want spinner to select a particulate spinner position. </p>
  
  <p>Can any one please tell me what is the best way to implement this. </p>
  
  <p>I have tried following but doesn't met my requirement 
  <a href="https://gist.github.com/granoeste/2786663" rel="nofollow noreferrer">https://gist.github.com/granoeste/2786663</a>
  <a href="https://stackoverflow.com/questions/24712540/set-key-and-value-in-spinner/24712664">Set Key and Value in spinner</a></p>
  
  <p>Write now I am using LinkedHashMapAdapter. But issue is that here I need to store position in DB or local shared preference . I don't think this a better solution </p>
  
  <p>Current Implementation </p>
  
  <pre><code>LinkedHashMap localeList = new LinkedHashMap&lt;&gt;();
  
          for (Map.Entry&lt;String, String&gt; val : map.entrySet()) {
              int resourceId = getResources().getIdentifier(val.getValue(), "string", getPackageName());
              localeList.put(val.getKey(), getResources().getString(resourceId));
  
          }
          LinkedHashMapAdapter&lt;String, String&gt; arrayAdapter = new LinkedHashMapAdapter&lt;&gt;(this, R.layout.spinner_layout, localeList);
          arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  
          mLocale.setAdapter(arrayAdapter);
          String localPosSelected = PreferencesHelper.getSharedPreferenceString(this, Constants.PREF_LOCALE_POS_KEY);
          if(localPosSelected!=null){
              mLocale.setSelection(Integer.parseInt(localPosSelected));
          }
  </code></pre>
  
  <p>Also is there an option to selected item of Spinner by value</p>