I am not able to display image from my local storage in android -


i have 20k image files in folder inside local storage, need display image file name local storage. how it? attached code here:

 if (environment.getexternalstoragestate()             .equals(environment.directory_pictures)) {         string filepath = file.separator + "sdcard" + file.separator + "android" + file.separator + "obb" + file.separator + "convertmp3todb" + file.separator + "ldoce6pics" + file.separator + filename;         try {             fileinputstream fis = new fileinputstream(filepath);             string entry = null;             while ((entry = fis.tostring()) != null) {                 if (!entry.tostring().isempty()) {                     file mytemp = file.createtempfile("tcl", "jpg", getcontext().getcachedir());                     mytemp.deleteonexit();                     fileoutputstream fos = new fileoutputstream(mytemp);                     (int c = fis.read(); c != -1; c = fis.read()) {                         try {                             fos.write(c);                         } catch (ioexception e) {                             e.printstacktrace();                         }                     }                     fos.close();                     fileinputstream myfile = new fileinputstream(mytemp);                     final bitmap bit = bitmapfactory.decodestream(myfile);                     imageview.setimagebitmap(bit);                  }             }             fis.close();          } catch (ioexception e) {             e.printstacktrace();          }     } 

 if (environment.getexternalstoragestate()             .equals(environment.directory_pictures)) {         string filepath = file.separator + "sdcard" + file.separator + "android" + file.separator + "obb" + file.separator + "convertmp3todb" + file.separator + "ldoce6pics" + file.separator + filename;         file f = new file(filepath);          if(f.exits()){              bitmap bm = bitmapfactory.decodefile(f.getabsolutepath());             imageview.setimagebitmap(bm);           }else{              // invalid path            }      }   } 

update section:

if (environment.getexternalstoragestate()                 .equals(environment.directory_pictures)) {   // never true see below image   } 

enter image description here

you have this

 file file  = new file(environment.getexternalstoragestate()+"/android/obb/convertmp3todb/ldoce6pics/"+filename);          if (file.exists()) {             // condition should ne likr this.         } 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -