title: How to get image path from images stored on sd card
body: <p>is it possible to get the path of all the images that are stored on the sd card of my android phone? also is it possible to check for other images stored on sd card or in the internal memory? I am currently doing this:</p>
  
  <pre><code>Cursor cur = this.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, null, null,null);  
          startManagingCursor(cur);  
          cur.moveToFirst();
          while (cur.moveToNext()) {
              String str = cur.getString(cur.getColumnIndex(MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME));
              Log.e("#########",str);
          }
  </code></pre>
  
  <p>this seems as if  returns the directories names,
  also I have seen this code:</p>
  
  <pre><code>File images = Environment.getDataDirectory();  
          File[] imagelist = images.listFiles(new FilenameFilter(){  
          public boolean accept(File dir, String name)  
          {  
              return ((name.endsWith(".jpg"))||(name.endsWith(".png")));  
          }  
      });  
          String []mFiles = new String[imagelist.length];  
  
          for(int i= 0 ; i&lt; imagelist.length; i++)  
          {  
              mFiles[i] = imagelist[i].getAbsolutePath();  
          }  
          Uri[] mUrls = new Uri[mFiles.length];  
  
          for(int i=0; i &lt; mFiles.length; i++)  
          {  
              mUrls[i] = Uri.parse(mFiles[i]);  
              Log.e("###############","MURIS: "+mUrls[i].getEncodedPath());
          }     
  </code></pre>
  
  <p>but this is throwing a nullpointer  exception .</p>