この質問は、カメラでキャプチャした画像を特定のフォルダーに保存する方法 [このような] の他のいくつかの質問と比較して、繰り返しのように思えるかもしれませんが、まだ問題が発生しています。私がやろうとしているのは、カメラで写真を撮った後、画像が新しいフォルダー (アプリ名にちなんで名付けられた) に保存されるアプリを作成することです。フォルダが作成されたように見えますが、画像が挿入されていないようです。以下は、私が失敗していると思われるコードの一部です。そこにどんな助けも大きな助けになるでしょう。ありがとうございました!
camera.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, cameraData);
}
});
}
private void saveToFile(String message) throws Exception {
String filePath = getFilesDir()+"";
File file = new File(filePath + "/sdcard/DCIM/100MEDIA/Wardobe");
FileOutputStream out = new FileOutputStream(file, true);
out.write(message.getBytes());
out.close();
saveImage(filePath, "/sdcard/DCIM/100MEDIA/Wardobe/image.jpg", bmp);
if(battleborn != null) {
saveImage(filePath, "sdcard/DCIM/100MEDIA/Wardrobe/image.jpg", bmp);
}
}
public void saveImage(String path, String dir, Bitmap image) {
try{
FileOutputStream fos = new FileOutputStream(path + dir);
BufferedOutputStream stream = new BufferedOutputStream(fos);
bmp.compress(CompressFormat.JPEG, 50, stream);
stream.flush();
stream.close();
}
catch(FileNotFoundException e) {
e.printStackTrace();
}
catch(IOException e) {
e.printStackTrace();
}
}