private String getParentDir(String path) {
   try {
     path = new URI(Util.PathToURI(path + "/..")).normalize().getPath();
   } catch (URISyntaxException e) {
     e.printStackTrace();
   }
   return Util.stripTrailingSlash(path);
 }
  public boolean browse(String directoryName) {
    if (this.mCurrentDir == null) {
      // We're on the storage list
      String storages[] = Util.getMediaDirectories();
      for (String storage : storages) {
        storage = Util.stripTrailingSlash(storage);
        if (storage.endsWith(directoryName)) {
          this.mCurrentRoot = storage;
          this.mCurrentDir = storage;
          this.mCurrentDir = Util.stripTrailingSlash(this.mCurrentDir);
          break;
        }
      }
    } else {
      try {
        this.mCurrentDir =
            new URI(Util.PathToURI(this.mCurrentDir + "/" + directoryName)).normalize().getPath();
        this.mCurrentDir = Util.stripTrailingSlash(this.mCurrentDir);

        if (this.mCurrentDir.equals(getParentDir(this.mCurrentRoot))) {
          // Returning on the storage list
          this.mCurrentDir = null;
          this.mCurrentRoot = null;
        }
      } catch (URISyntaxException e) {
        Log.e(TAG, "URISyntaxException in browse()", e);
        return false;
      } catch (NullPointerException e) {
        Log.e(TAG, "NullPointerException in browse()", e);
        return false;
      }
    }

    Log.d(TAG, "Browsing to " + this.mCurrentDir);

    if (directoryName.equals("..")) this.mCurrentNode = this.mCurrentNode.parent;
    else {
      this.mCurrentNode = this.mCurrentNode.getChildNode(directoryName);
      if (mCurrentNode.subfolderCount() < 1) {
        // Clear the ".." entry
        this.mCurrentNode.children.clear();
        this.populateNode(mCurrentNode, mCurrentDir);
      }
    }

    this.notifyDataSetChanged();
    return true;
  }
 public String getMediaLocation(int position) {
   if (position >= mCurrentNode.children.size()) return null;
   return Util.PathToURI(this.mCurrentDir + "/" + mCurrentNode.children.get(position).name);
 }