title: Ionic: File Download in custom directory
body: <p>i want to download the file in specific folder and sub folder. </p>
  
  <p>Code:-</p>
  
  <pre><code>  var directoryPath = "";
      $ionicPlatform.ready(function () {
          window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
              function (fileSystem) {
                  var directoryEntry = fileSystem.root; // to get root path to directory
                  console.log("directoryEntry=");
                  console.log(directoryEntry);
                  directoryEntry.getDirectory("XYZ/", { create: true, exclusive: false },
                      function (Success) {
                          console.log("Directory Sucess"); console.log(Success);
                          Success.getDirectory("ABC/", { create: true, exclusive: false },
                              function (SubDirectory) {
                                  console.log(SubDirectory);
                                  directoryPath = SubDirectory.nativeURL;
                                  if ($localStorage.ProfileImage !== undefined &amp;&amp; $localStorage.ProfileURL !== "") {
                                      var ServerProfileFile = $localStorage.ProfileImage.substr($localStorage.ProfileImage.lastIndexOf('/') + 1);
                                      var localProfileFile = "";
                                      if ($localStorage.ProfileURL !== undefined &amp;&amp; $localStorage.ProfileURL !== "") {
                                          localProfileFile = $localStorage.ProfileURL.substr($localStorage.ProfileURL.lastIndexOf('/') + 1);
                                      }
                                      if (ServerProfileFile !== localProfileFile) {
                                          // var fp = ;
                                          // console.log(fp);
                                          var fileTransfer = new FileTransfer();
  
                                          fileTransfer.download(encodeURI($localStorage.ProfileImage), directoryPath + ServerProfileFile,
                                              function (entry) {
                                                  console.log(entry);
                                                  console.log("download complete: " + entry.fullPath);
                                                  $localStorage.ProfileURL = entry.nativeURL;
                                                  ProfileImage.Image = $localStorage.ProfileURL;
  
                                              },
                                              function (error) {
  
                                                  $localStorage.ProfileURL = $localStorage.ProfileImage;
                                                  ProfileImage.Image = $localStorage.ProfileURL;
  
                                              });
  
                                      } else {
                                          $cordovaFile.checkFile(directoryPath, localProfileFile)
                                              .then(function (Filesuccess) {
  
                                                  ProfileImage.Image = $localStorage.ProfileURL;
  
                                              }, function (error) {
  
                                                  var fileTransfer = new FileTransfer();
  
                                                  fileTransfer.download(encodeURI($localStorage.ProfileImage), directoryPath + ServerProfileFile,
                                                      function (entry) {
                                                          console.log(entry);
                                                          console.log("download complete: " + entry.fullPath);
                                                          $localStorage.ProfileURL = entry.nativeURL;
                                                          ProfileImage.Image = $localStorage.ProfileURL;
  
                                                      },
                                                      function (error) {
                                                $localStorage.ProfileURL = $localStorage.ProfileImage;
                                                          ProfileImage.Image = $localStorage.ProfileURL;
  
                                                      });
  
                                              });
  
                                      }
  
                                  }
                                  $scope.$apply();
  
                              },
                              function (SubErrror) {
                                  console.log("Directory Fail SubErrror"); console.log(SubErrror);
                              });
  
                      }, function (error) {
                          console.log("Directory Fail"); console.log(error);
                      });
              },
              function () {
                  console.log("error getting LocalFileSystem");
              });
      });
  </code></pre>
  
  <p>it is downloading the file but saving at the location "file:///data/data/com.greatdevelopers.XYZ/files/files/XYZ/ABC/3705db1c-5519-47f1-b716-c7c9324390aa_26183.jpeg"
  and i did not find such location in my phone internal as well as external memory</p>
  
  <p>please tell me where i am doing wrong. Thanks</p>