@Override
 public void onClick(DialogInterface dialog, int which) {
   if (dialog != null && dialog.equals(confirmDlg)) {
     if (which == Dialog.BUTTON_POSITIVE && selectedPath != null) {
       ConfigurationManager.instance().setStoragePath(selectedPath);
       COConfigurationManager.setParameter(
           "General_sDefaultTorrent_Directory",
           com.frostwire.android.gui.util.SystemUtils.getTorrentsDirectory().getAbsolutePath());
       dismissPreferenceDialog();
       uxLogSelection();
     }
   } else {
     super.onClick(dialog, which);
   }
 }
  @LargeTest
  public void testDownload1() throws IOException {

    HttpClient c = HttpClientFactory.getInstance(HttpClientFactory.HttpContext.MISC);

    File torrentFile =
        new File(SystemUtils.getTorrentsDirectory(), "create_download_test1.torrent");
    File saveDir = SystemUtils.getTorrentDataDirectory();
    c.save(TorrentUrls.FROSTCLICK_BRANDON_HINES_2010, torrentFile);

    final CountDownLatch signal = new CountDownLatch(1);

    VuzeDownloadManager dm =
        VuzeDownloadFactory.create(
            torrentFile.getAbsolutePath(),
            null,
            saveDir.getAbsolutePath(),
            new VuzeDownloadListener() {

              @Override
              public void stateChanged(VuzeDownloadManager dm, int state) {
                if (state == VuzeDownloadManager.STATE_STOPPED) {
                  signal.countDown();
                }
              }

              @Override
              public void downloadComplete(VuzeDownloadManager dm) {}
            });

    assertNotNull(dm);

    VuzeUtils.remove(dm, true);

    assertTrue("Unable to remove the download", TestUtils.await(signal, 10, TimeUnit.SECONDS));
  }
 protected File getFinalFile(File savePath, byte fileType) {
   File path = SystemUtils.getSaveDirectory(fileType);
   File finalFile = new File(path, savePath.getName());
   return finalFile;
 }