1
URL에서 파일을 읽고 내 sdcard에 쓰려고합니다. .js .css 및 .txt 파일 등의 다른 파일과 잘 작동하므로 .png .jpg .bmp 및 .gif와 함께 작동하지 않습니다. 이에 대한 나의 코드는 비트 맵을 사용하여 파일을 읽는 사용해보십시오 내가이안드로이드에서 SDCard로 이미지를 읽고 쓰십시오.
URL에서 파일을 읽고 내 sdcard에 쓰려고합니다. .js .css 및 .txt 파일 등의 다른 파일과 잘 작동하므로 .png .jpg .bmp 및 .gif와 함께 작동하지 않습니다. 이에 대한 나의 코드는 비트 맵을 사용하여 파일을 읽는 사용해보십시오 내가이안드로이드에서 SDCard로 이미지를 읽고 쓰십시오.
private void storeImage(Bitmap image) {
File pictureFile = getOutputMediaFile();
if (pictureFile == null) {
Log.d(TAG,
"Error creating media file, check storage permissions: ");// e.getMessage());
return;
}
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
image.compress(Bitmap.CompressFormat.PNG, 90, fos);
fos.close();
} catch (FileNotFoundException e) {
Log.d(TAG, "File not found: " + e.getMessage());
} catch (IOException e) {
Log.d(TAG, "Error accessing file: " + e.getMessage());
} }
강타하고 여기에 도와주세요
String path = dir + value;
File localConfigfile = new File(
Environment.getExternalStorageDirectory()
+ "/Avalon/assets/www/" + path);
String responseString = RequestMgr.GetWebSource(DomainName
+ "/" + Heirarchy + "/" + Serverpath);
FileOutputStream out;
if (localConfigfile.exists()) {
localConfigfile.delete();
out = new FileOutputStream(localConfigfile);
out.write(responseString.getBytes());
}
}
입니다. 성능을 위해 비트 맵과 URI를 사용하는 경우 좋은 옵션이 될 것입니다.
샘플 또는 코드의 링크를 제공해 줄 수 있습니까? –