로컬 저장소의 폴더에 20k 개의 이미지 파일이 있습니다. 로컬 저장소의 파일 이름으로 이미지를 표시해야합니다. 그것을하는 방법? 나는 여기에 내 코드를 첨부 :android의 로컬 저장소에서 이미지를 표시 할 수 없습니다.
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);
for (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();
}
}
모든 로그 캣 오류처럼해야 할
를? – Nisarg
show ur logcat log – MobDev
시도해보십시오. 글라이드와 같은 이미지 라이브러리를 사용하십시오 (글라이드를 선호하는 다른 사람들도 있습니다) - 문자열에서 uri로 파일 경로를 변환하는 경우 2. 비트 맵으로 로더를 설정할 수도 있습니다 – MobDev