title: permission denied write with USB pen drive
body: <p>this is my AndroidManifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.abc2"
      android:versionCode="1"
      android:versionName="1.1.8" &gt;
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="18" /&gt;
  
      &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
      &lt;uses-permission android:name="android.permission.DISABLE_KEYGUARD" /&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
      &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; 
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  </code></pre>
  
  <p>and i m trying to copy the apps's database to USB pendrive, last time are using SD card, it is working fine, but after i have change the SD card path to <code>/mnt/sda/sda2</code> it is error permission denied, <code>/mnt/sda/sda2</code> is the USB pendrive path</p>
  
  <p>this is the copy file function to copy the database to pendrive </p>
  
  <pre><code>private void copyFile(String inputPath, String inputFile, String outputPath) {
  
          InputStream in = null;
          OutputStream out = null;
          try {
  
              //create output directory if it doesn't exist
              File dir = new File (outputPath); 
              if (!dir.exists())
              {
                  dir.mkdirs();
              }
  
  
              in = new FileInputStream(inputPath + inputFile);        
              out = new FileOutputStream(outputPath + inputFile);
  
              byte[] buffer = new byte[1024];
              int read;
              while ((read = in.read(buffer)) != -1) {
                  out.write(buffer, 0, read);
              }
              in.close();
              in = null;
  
                  // write the output file (You have now copied the file)
                  out.flush();
              out.close();
              out = null;  
              Toast.makeText(UltilityActivity.this, "Export successful!", Toast.LENGTH_SHORT).show();
  
          }  catch (FileNotFoundException fnfe1) {
              Log.e("tag", fnfe1.getMessage());
              Toast.makeText(UltilityActivity.this, "Export failed", Toast.LENGTH_SHORT).show();
          }
                  catch (Exception e) {
              Log.e("tag", e.getMessage());
              Toast.makeText(UltilityActivity.this, "Export failed", Toast.LENGTH_SHORT).show();
          }
  
      }    
  }
  </code></pre>
  
  <p>this is how i call the copyfile function</p>
  
  <pre><code>copyFile("/data/data/com.example.abc2/databases/","DB_BusData","/mnt/sda/sda2/");
  </code></pre>
  
  <p>last time is copied to SD card , with this code</p>
  
  <pre><code>copyFile("/data/data/com.example.abc2/databases/","DB_BusData","/mnt/sdcard/");
  </code></pre>
  
  <p>copied to SD card are working, but USB pendrive errror with :-</p>
  
  <pre><code>03-10 10:58:13.204: D/MainActivity(1832): open failed: EACCES (Permission denied)
  03-10 10:58:13.204: D/MainActivity(1832): java.io.IOException: open failed: EACCES (Permission denied)
  </code></pre>
  
  <p>it is need to mount USB drive? can i mount in programmatically ? how? please give me an example?</p>