title: How to go back to parent directory on back button press?
body: <p>Below is my code, which checks whether the selected file is a directory or a file. If it is a directory it changes into it. But how do I goes back to parent directory on back button press?</p>
  
  <p>I see somehwere in Stackflow a code which goes <code>root.parent</code> when backpress but now I did not found that code.</p>
  
  <pre><code>    gridView =(GridView)findViewById(R.id.grid);
      gridView.setOnItemClickListener(new OnItemClickListener(){
      public void onItemClick(AdapterView&lt;?&gt; parent, View view, int 
      position,long id) {
  
  
      if(currentFiles[position].isDirectory())
      {
          root = new File("/data/data/com.myexample
   /files/"+FileName(currentFilePath[position])+"/");
  
          Log.e("Root first",root+ " ");
  
          currentFiles = root.listFiles();
  
          inflateListView(currentFiles);
      }
  
  
       private void inflateListView(File[] files){
  
  
  List&lt;Map&lt;String,Object&gt;&gt; listItems = new ArrayList&lt;Map&lt;String,Object&gt;&gt;();
  
  
  for(int i=0;i&lt;files.length;i++)
  
  {       
      Map&lt;String, Object&gt; listItem = new HashMap&lt;String, Object&gt;();
  
      if(files[i].isDirectory())
      {
          listItem.put("icon", R.drawable.folder);
      }
      else
      {
          listItem.put("icon", R.drawable.file);
      }
  
      listItem.put("fileName", files[i].getName());
      listItems.add(listItem);
    }
  
  simpleAdapter=new SimpleAdapter(this,listItems,R.layout.line,new String[]
  {"icon","fileName"},new int[]{R.id.icon,R.id.file_name});
  gridView.setAdapter(simpleAdapter);
  </code></pre>