Hey I am currently trying to create a path and file for an image i am storing from the camera. There seems to a be a problem with path I am trying to create though. In the following method, Im getting an IO.FileNotFound error on this line: fileOutputStream = new FileOutputStream(
sdImageMainDirectory.toString() +"/" + expName + ".jpg");
java.io.FileNotFoundException: /mysdcard/myImages/ImageName.jpg
sdImageMainDirectory.toString() +"/" + expName + ".jpg");
java.io.FileNotFoundException: /mysdcard/myImages/ImageName.jpg
Code:
public static boolean StoreByteImage(Context mContext, byte[] imageData,
int quality, String expName) {
File sdImageMainDirectory = new File("/mysdcard/myImages");
sdImageMainDirectory.mkdirs();
FileOutputStream fileOutputStream = null;
try {
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 5;
Bitmap myImage = BitmapFactory.decodeByteArray(imageData, 0,
imageData.length,options);
fileOutputStream = new FileOutputStream(
sdImageMainDirectory.toString() +"/" + expName + ".jpg");
BufferedOutputStream bos = new BufferedOutputStream(
fileOutputStream);
myImage.compress(CompressFormat.JPEG, quality, bos);
bos.flush();
bos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}