Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't create file in sd-card
    primarykey
    data
    text
    <p>I am trying to save a bitmap to a file and then saving it on sd-card. Here's my code:</p> <pre><code>String path = Environment.getExternalStorageDirectory().toString(); File file = new File(path, "Jhs"+".jpg"); file.mkdir(); OutputStream fOut; try { fOut = new FileOutputStream(file); BitmapMatrix convMatrix = new BitmapMatrix(0); convMatrix.result.compress(Bitmap.CompressFormat.JPEG, 100, fOut); fOut.flush(); fOut.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre> <p>Also this code is in a class which does not extend Activity.I am just giving this information thinking that maybe there is some issue with this. Here's my LogCat</p> <pre><code>05-01 18:00:22.555: W/System.err(31392): java.io.FileNotFoundException: /mnt/sdcard/Jhs.jpg (Permission denied) 05-01 18:00:22.555: W/System.err(31392): at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method) 05-01 18:00:22.555: W/System.err(31392): at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232) 05-01 18:00:22.555: W/System.err(31392): at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:94) 05-01 18:00:22.555: W/System.err(31392): at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:66) 05-01 18:00:22.555: W/System.err(31392): at com.example.imageprocess.BitmapMatrix.computeConvolution3x3(BitmapMatrix.java:123) 05-01 18:00:22.555: W/System.err(31392): at com.example.imageprocess.MainActivity.sharpen(MainActivity.java:105) 05-01 18:00:22.555: W/System.err(31392): at com.example.imageprocess.MainActivity.onCreate(MainActivity.java:51) 05-01 18:00:22.555: W/System.err(31392): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072) 05-01 18:00:22.555: W/System.err(31392): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1836) 05-01 18:00:22.555: W/System.err(31392): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893) 05-01 18:00:22.555: W/System.err(31392): at android.app.ActivityThread.access$1500(ActivityThread.java:135) 05-01 18:00:22.555: W/System.err(31392): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054) 05-01 18:00:22.555: W/System.err(31392): at android.os.Handler.dispatchMessage(Handler.java:99) 05-01 18:00:22.565: W/System.err(31392): at android.os.Looper.loop(Looper.java:150) 05-01 18:00:22.565: W/System.err(31392): at android.app.ActivityThread.main(ActivityThread.java:4389) 05-01 18:00:22.565: W/System.err(31392): at java.lang.reflect.Method.invokeNative(Native Method) 05-01 18:00:22.565: W/System.err(31392): at java.lang.reflect.Method.invoke(Method.java:507) 05-01 18:00:22.565: W/System.err(31392): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849) 05-01 18:00:22.565: W/System.err(31392): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607) 05-01 18:00:22.565: W/System.err(31392): at dalvik.system.NativeStart.main(Native Method) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload