Reputation: 1889
I'm new to android camera API , there's a PictureCallback invoked in the code with :
PictureCallback jpegCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
// Save the image JPEG data to the SD card
FileOutputStream outStream = null;
try {
String path = Environment.getExternalStorageDirectory() +"\test.jpg";
outStream = new FileOutputStream(path);
outStream.write(data);
outStream.close();
} catch (FileNotFoundException e) {
Log.e(TAG, "File Note Found", e);
} catch (IOException e) {
Log.e(TAG, "IO Exception", e);
}
}
};
The exception pointed out to this line :
outStream = new FileOutputStream(path);
Since I'm new to Android world, I don't know where's exactly this Environment.getExternalStorageDirectory() points out.
The exception says :
Java.io.FileNotFoundException: /storage/emulated/0 est.jpg: open failed: EACCES (Permission denied)
But in my manifest :
<uses-feature android:name="android.hardware.Camera"/>
<uses-permission android:name="android.permission.CAMERA"/>
EDIT : I fixed the path to
String path = Environment.getExternalStorageDirectory() +"/test.jpg";
But still gives me :
java.io.FileNotFoundException: /storage/emulated/0/test.jpg: open failed: EACCES (Permission denied)
Upvotes: 0
Views: 1256
Reputation: 3388
java.io.FileNotFoundException: /storage/emulated/0/test.jpg: open failed: EACCES (Permission denied)
you must have forgot to add
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Upvotes: 2
Reputation: 93728
Android uses linux. The path separator is /
not \
. Also \t
puts in a tab, if you wanted an actual \
you need to use \\t
Upvotes: 1