title: Automatically getting the path of a folder in listview via its position
body: <p>there is a listview of all the folders of external storage in my xml file. when user clicks on any folder it allows him to add a file in that folder in my program. when user clicks on that folder it should automatically get the path of that folder as destination to store that file.user can give source folder path via browse and select.. is there any way i can do that by getting position of that folder in listview? um using following code to copy the file from source folder to destination folder</p>
  
  <pre><code>        public void copy(File src, File dst) throws IOException {
                   FileInputStream inStream = new FileInputStream(src);
                   FileOutputStream outStream = new FileOutputStream(dst);
                   FileChannel inChannel = inStream.getChannel();
                   FileChannel outChannel = outStream.getChannel();
                   inChannel.transferTo(0, inChannel.size(), outChannel);
                   inStream.close();
                   outStream.close();
               }
  </code></pre>
  
  <p>i used this code to show all the folders within my app directory(ABC) in external storage</p>
  
  <pre><code>                        try {
              ListView lv;
              File ppath=Environment.getExternalStorageDirectory();
              ArrayList&lt;String&gt; FilesInFolder = GetFiles(ppath+"/ABC");
              lv = (ListView)findViewById(R.id.filelist);
              lv.setAdapter(new ArrayAdapter&lt;String&gt;(this,
                  android.R.layout.simple_list_item_1, FilesInFolder));
  
              lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
              @Override
              public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
                      long arg3) {
                  // TODO Auto-generated method stub
  
              }
              });
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
  
  }
  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();
      if (files.length == 0)
          return null;
      else {
          for (int i=0; i&lt;files.length; i++) 
              MyFiles.add(files[i].getName());
      }
  
      return MyFiles;
  }   
  </code></pre>
  
  <p>}</p>