android - Want just the filename to show in array and not the whole path -


i need file name of files in app folder coming whole path/storage/emulated/0/appfolder/file1.pdf. how cani have file.pdf show instead of whole path. please advise

 arraylist<file> files = new arraylist<file>(); @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate); file file[] =  environment.getexternalstoragepublicdirectory("/appfolder").listfiles();     recursivefilefind(file);      setlistadapter(new arrayadapter<file>(viewinspection.this,             android.r.layout.simple_list_item_1, files));     toast.maketext(this, "" + files.size(), toast.length_long).show(); }  public void recursivefilefind(file[] file1) {     int = 0;     string filepath = "";     if (file1 != null) {         while (i != file1.length) {             filepath = file1[i].getabsolutepath();             files.add(file1[i]);             if (file1[i].isdirectory()) {                 file file[] = file1[i].listfiles();                 recursivefilefind(file);             }else{                             }              i++;             log.d(i + "", filepath);         }     } }} 

use file.getname() instead of file.getabsolutepath()

    while (i != file1.length) {         filepath = file1[i].getname();// here         files.add(file1[i].getname());//updated here          if (file1[i].isdirectory()) {              file file[] = file1[i].listfiles();              recursivefilefind(file);             }               i++;              //log.d(i + "", filepath); //update toast.maketext(getactivity(), filepath, toast.length_long).show();          } 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -