I want to save an bitmap as screenshot into an /fraktal folder. Every time i try this i get an Error saying EACCESS permission denied at file.createNewFile()
.
I already added the permissions at AndroidManifest.xml
.
uses-permission android:name="android.permission.INTERNET"
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
May u help?
private void takeScreenshot(Bitmap fractal)
{
String filename="fraktal_"+ System.currentTimeMillis();
FileOutputStream out = null;
File path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES).getAbsoluteFile();
File file = new File(path,"/fraktal/"+filename +".png");
try {
path.mkdirs();
file.createNewFile();
out = new FileOutputStream(file);
fractal.compress(Bitmap.CompressFormat.PNG, 100, out);// PNG ist verlustfrei, kompression 100 wird ignoriert
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (out != null)
{
out.flush();
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}