title: How do i open an image by clicking on a listview in android?
body: <p>So, here is the thing. I wanted to experiment a bit. So, i wrote this program which looks for images with (.jpg) extension in my mnt/shared/Newpictures folder in my GennyMotion Emulator. In my program, i captured the name of the files with .jpg extension in a String array adapter and the file path in a filepath string array. Now, here is the part where i am blank, i have the path,name and i can get the position by clicking on the list. But how do i open the image when i click on the list. I researched online and most of the codes were too confusing. So, may be someone can suggest me an easier approach. This is what i tried so far. Thanks.</p>
  
  <pre><code>package com.example.user.imageapp;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.ListView;
  
  import java.io.File;
  import java.util.ArrayList;
  
  /**
   * Created by user on 06-08-2015.
   */
  
  
  public class Splash extends Activity {
      Button load;
      String s;
      private ListView mainList;
      private String[] FilePathStrings;
  
      ArrayList&lt;String&gt;filesinFolder = GetFiles("/mnt/shared/NewPictures");
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.splash);
        //  load = (Button)findViewById(R.id.Load);
          mainList = (ListView) findViewById(R.id.imagelist);
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1,filesinFolder );
  
          mainList.setAdapter(adapter);
  
          mainList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
                //what do i put here
  
  
              }
          });
  
  
  
  
      }
  
  
      public ArrayList&lt;String&gt; GetFiles(String DirectoryPath)
      {
          ArrayList&lt;String&gt; MyFiles = new ArrayList&lt;String&gt;();
          File f = new File(DirectoryPath);
          f.mkdirs();
  
          File[] files = f.listFiles();
  
          FilePathStrings = new String[files.length];
  
          for (int i = 0; i &lt; files.length; i++) {
              // Get the path of the image file
              if(files[i].getName().contains(".jpg")) {
                  FilePathStrings[i] = files[i].getAbsolutePath();
                  // Get the name image file
                  MyFiles.add(files[i].getName());
  
              }
          }
  
  
  
          return MyFiles;
  
  
      }
  }
  </code></pre>