title: populate list items from shared preferences data
body: <p>I am now trying to send data from <code>ListActivity</code> to another <code>ListActivity</code> by using <code>SharedPreferences</code>. I added data in <code>OnItemClickListener</code> with <code>SharedPreferences</code>. I have no idea how to populate data in another <code>ListActivity</code> using <code>ArrayList</code>. Below is the codes.</p>
  
  <pre><code>convertView.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              SharedPreferences pref = getContext().getSharedPreferences(
                      Constants.SHARED_PRED, 0);
              Editor edit = pref.edit();
  
              edit.putString("TITLE", getItem(position).title);
              edit.putString("CHAR", getItem(position).character);
              edit.putString("TOTAL", getItem(position).totalpages+"");
              edit.putString("THUMB", getItem(position).thumbnail);
              edit.putInt("CODE", getItem(position).code);
              edit.commit();
  
              System.out.println("Title &gt;&gt;&gt;&gt;&gt;&gt;" + getItem(position).title);
              System.out.println("Character &gt;&gt;&gt;&gt;&gt;&gt;" + getItem(position).character);
              System.out.println("Total &gt;&gt;&gt;&gt;&gt;&gt;" + getItem(position).totalpages);
              System.out.println("thumb url &gt;&gt;&gt;&gt;&gt;&gt;" + getItem(position).thumbnail);
              System.out.println("Code &gt;&gt;&gt;&gt;&gt;&gt;" + getItem(position).code);
  
              Intent i = new Intent(getContext(), DetailPager.class);
              i.putExtra("NPOS", position);
              getContext().startActivity(i);
          }
      });
  </code></pre>
  
  <p>My scenario is that i have two activity in my application. First Activity will launch <code>ListActivity</code> by using <code>SharedPreferences</code>. Second Activity will load <code>DetailPager.class</code> which is written in codes. My problem is that i don't know how to populate <code>ListActivity</code> which is not launch in <code>OnClick</code> event.</p>
  
  <p><strong>My ListActivity Class</strong></p>
  
  <pre><code>private ListViewAdapter m_adapter;
  public ArrayList&lt;String&gt; cat = new ArrayList&lt;String&gt;();
  private SharedPreferences preferences;
  private SharedPreferences.Editor editor;
  String title, character, thumbnail, totalPages;
  int Code;
  
  TextView titleView, charView, totalView;
  ImageView thumbView, removeView;
  Uri thumbUri;
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setTheme(android.R.style.Theme_Black_NoTitleBar);
      getWindow().requestFeature(Window.FEATURE_NO_TITLE);
      setContentView(R.layout.myputet);
      init_UI();
  }
  
  public void init_UI() {
      preferences = getApplicationContext().getSharedPreferences(
              Constants.SHARED_PRED, 0);
      editor = preferences.edit();
  
      title = preferences.getString("TITLE", "");
      character = preferences.getString("CHAR", "");
      thumbnail = preferences.getString("THUMB", "");
      thumbUri = Uri.parse(thumbnail);
      totalPages = preferences.getString("TOTAL", "");
      Code = preferences.getInt("CODE", 0);
  
      System.out.println("Getting Title " + title);
      System.out.println("Getting character " + character);
      System.out.println("Getting thumbnail " + thumbnail);
      System.out.println("Getting thumbUri " + thumbUri);
      System.out.println("Getting totalPages " + totalPages);
  
      ListView lv = (ListView) findViewById(R.id.listview);
      m_adapter = new ListViewAdapter(this, R.layout.myputet_item, cat);
      lv.setAdapter(m_adapter);
  }
  
  private class ListViewAdapter extends ArrayAdapter&lt;String&gt; {
      private ArrayList&lt;String&gt; items;
  
      public ListViewAdapter(Context context, int textViewResourceId,
              ArrayList&lt;String&gt; items) {
          super(context, textViewResourceId, items);
          this.items = items;
  
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          View v = convertView;
          if (v == null) {
              LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              v = vi.inflate(R.layout.myputet_item, null);
          }
          String info = items.get(position);
  
          if (info != null) {
              titleView = (TextView) v.findViewById(R.id.titleTxtView);
              charView = (TextView) v.findViewById(R.id.charTxtView);
              totalView = (TextView) v.findViewById(R.id.totalTxtView);
              thumbView = (ImageView) v.findViewById(R.id.charImageView);
              removeView = (ImageView) v.findViewById(R.id.removeListItem);
  
              titleView.setText(title);
              charView.setText(character);
              totalView.setText(totalPages);
              thumbView.setImageURI(thumbUri);
          }
          return v;
      }
  }
  
  @Override
  public void onSaveInstanceState(Bundle outState) {
      super.onSaveInstanceState(outState);
  
  }
  </code></pre>