title: How to pull file from my Android device to a local folder on my PC
body: <p>I'm trying to create a method that will pull a file from an Android device into a local path on my machine.</p>
  
  <p>I'm using the pullFile method from com.android.ddmlib and I'm getting this error:</p>
  
  <p><code>02:45:59 E/ddms: Failed to open local file C:\Users\amiyahav\Desktop\PullFile for writing, Reason: java.io.FileNotFoundException: C:\Users\amiyahav\Desktop\PullFile (Access is denied)
  02:45:59 E/Device: Error during Sync: Writing local file failed!</code></p>
  
  <p>This is my function:</p>
  
  <pre><code>public static void pullFile(@SuppressWarnings("rawtypes") AppiumDriver driver, String remote, String local) throws TimeoutException, FailureException, AdbCommandRejectedException, SyncException, IOException {
          AndroidDebugBridge.init(false);
          AndroidDebugBridge adb = AndroidDebugBridge.createBridge();
  
          String deviceUdid = (String) driver.getCapabilities().getCapability(MobileCapabilityType.UDID);
  
          long startTime = System.currentTimeMillis();
          while (!adb.isConnected() || !adb.hasInitialDeviceList()) {
              if (System.currentTimeMillis() - startTime &gt;= 20000)
                  throw new TimeoutException("Error occurred while loading devices list");
              try {
                  Thread.sleep(500);
              } catch (InterruptedException e) {
                  throw new FailureException("Action execution interrupted",e);
              }
          }
  
          adb.getDevices()[0].pullFile(remote, local);
      }
  </code></pre>
  
  <p>This is the JUnit test:</p>
  
  <pre><code>@Test
      public void runPullFileAndroid() throws Exception {
          String remote = "/data/hw_init/product/media/Pre-loaded/Music/Dream_It_Possible.flac";
          String local = "C:\\Users\\amiyahav\\Desktop\\PullFile";
          AndroidDriver driver = runner.getDriver();
          try {
              ADBHelper.pullFile(driver, remote, local);
          } catch (Exception e) {
              throw new FailureException("Failed running ADB shell command",e);
          }
  
      }
  </code></pre>
  
  <p>Any help will be appreciated!</p>