İlk olduğunu size Bitmap almak gerekir. Zaten bir nesne Bitmap olarak sağlayabilir veya gibi sen ImageView adresinden elde deneyebilirsiniz: Sonra SD karttan dizinde (bir File nesne) almak zorundadır
BitmapDrawable drawable = (BitmapDrawable) mImageView1.getDrawable();
Bitmap bitmap = drawable.getBitmap();
örneğin:
File sdCardDirectory = Environment.getExternalStorageDirectory();
Sonraki görüntü depolama için özel bir dosya oluşturmak: Bundan sonra
File image = new File(sdCardDirectory, "test.png");
, sadece gibi onun yöntemine compress için Bitmap sayesinde yazmak zorunda:
boolean success = false;
// Encode the file as a PNG image.
FileOutputStream outStream;
try {
outStream = new FileOutputStream(image);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
/* 100 to keep full quality of the image */
outStream.flush();
outStream.close();
success = true;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Son olarak, gerekirse, yalnızca boole sonucunu ele alın. Mesela:
if (success) {
Toast.makeText(getApplicationContext(), "Image saved with success",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(),
"Error during image saving", Toast.LENGTH_LONG).show();
}
Manifest'inizde aşağıdaki iznini ekleyin unutmayın:
cevaplar bir çok sorunuzun vardır
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
kullanmak arama ilk! http://stackoverflow.com/questions/4875114/android-save-image-from-url-onto-sd-card –