アプリケーションリソースからSDカード上のファイルに実際の画像を保存して、メッセージングアプリケーションからアクセスできるようにしようとしていますが、次のエラーが発生します-FileOutputStreamタイプのwrite(byte [])メソッドは適用できません引数用(Drawable)-保存する場所。実際の画像自体を保存するための適切な方法を使用しておらず、解決策を見つけるのに苦労していると思います。
// Selected image id
int position = data.getExtras().getInt("id");
ImageAdapter imageAdapter = new ImageAdapter(this);
ChosenImageView.setImageResource(imageAdapter.mThumbIds[position]);
Resources res = getResources();
Drawable drawable = res.getDrawable(imageAdapter.mThumbIds[position]); //(imageAdapter.mThumbIds[position]) is the resource ID
try {
File file = new File(dataFile, FILENAME);
file.mkdirs();
FileOutputStream fos = new FileOutputStream(file);
fos.write(drawable); // supposed to save the image here, getting the error at fos.write
fos.close();
}catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}