title: Refresh listview after renaming a file using base adapter
body: <p>I am getting my folder files in listview through arraylist . @ on click on something I rename a file but my listview is not refresh by using adapter.datasetnotifychanged. I am using custom base adapter. can any tell me how I automatically refresh list after "rename from" to "rename to" file.  </p>
  
  <p>Adapter.class</p>
  
  <pre><code>public class CustomAdapter extends BaseAdapter {
  Context context;
  ArrayList&lt;String&gt; countryList;
  LayoutInflater inflter;
  
  public CustomAdapter(Context applicationContext, ArrayList&lt;String&gt; countryList) {
      this.context = context;
      this.countryList = countryList;
  
      inflter = (LayoutInflater.from(applicationContext));
  }
  
  @Override
  public int getCount() {
      return countryList.size();
  }
  
  
  @Override
  public Object getItem(int i) {
      return null;
  }
  
  @Override
  public long getItemId(int i) {
      return 0;
  }
  
  @Override
  public View getView(int position, View view, ViewGroup viewGroup) {
      view = inflter.inflate(R.layout.list_items, null);
      String hello = countryList.get(position);
      Log.d("Hello",hello);
  
      TextView country = (TextView) view.findViewById(R.id.textView);
      country.setText(hello.substring(0, hello.lastIndexOf(")")+1));
  
      return view;
  }
  </code></pre>
  
  <p>Rename.class</p>
  
  <pre><code> File sdCardRoot = Environment.getExternalStorageDirectory();
      yourDir = new File(sdCardRoot, "/MoreData/closed");
     FilesInFolder = GetFiles(yourDir);
     if(FilesInFolder!=null) {
     customAdapter = new CustomAdapter(getActivity(), FilesInFolder);
     lv.setAdapter(customAdapter);
     customAdapter.notifyDataSetChanged();
     lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              final File file = new File(path.get(position));
              value_new = FilesInFolder.get(position).toString();
              File from = new File(root,String.valueOf(file.getName()));
              File to = new File(root,String.valueOf(file.getName()).substring(0,file.getName().lastIndexOf(")")+1)+newencrypt);
          from.renameTo(to);}
  
  
  public ArrayList&lt;String&gt; GetFiles(File DirectoryPath) {
      ArrayList&lt;String&gt; MyFiles = new ArrayList&lt;String&gt;();
      File f = new File(String.valueOf(DirectoryPath));
      f.mkdirs();
      File[] files = f.listFiles();
      if (files.length == 0)
          return null;
      else {
          for (int i=0; i&lt;files.length; i++)
              MyFiles.add(files[i].getName());
      }  
      return MyFiles;
  }
   private void getDir(String dirPath)
  {
      item = new ArrayList&lt;String&gt;();
      path = new ArrayList&lt;String&gt;();
      File f = new File(dirPath);
      File[] files = f.listFiles();
      if(!dirPath.equals(root))
      {
          item.add(root);
          path.add(root);
          item.add("../");
          path.add(f.getParent());
      }
  
      for(int i=0; i &lt; files.length; i++)
      {
          File file = files[i];
  
          if(!file.isHidden() &amp;&amp; file.canRead()){
              path.add(file.getPath());
              if(file.isDirectory()){
                  item.add(file.getName() + "/");
              }else{
                  item.add(file.getName());
              }
          }
      }
  </code></pre>