Can't save my picture
Posted
by
mamii
on Stack Overflow
See other posts from Stack Overflow
or by mamii
Published on 2012-09-15T15:35:44Z
Indexed on
2012/09/15
15:37 UTC
Read the original article
Hit count: 138
I want to save the image that I draw, but I always failure is reported. I have tested and tried but I can correct any errors. Therefore, I appeal to you. This store is for me as a "cancer sore". And what is the drawing application without the possibility shranjevnja? sucks: D Question: What is wrong with my code for storage? or anything else? Posts:
09-12 07:30:34.346: E / Panel (8003): IOEception
09-12 07:30:34.346: E / Panel (8003): java.io.IOException: Parent directory of file does not exist: / sdcard/anppp/2012Sep1273034.png
09-12 07:30:34.346: E / Panel (8003): at java.io.File.createNewFile (File.java: 1263)
09-12 07:30:34.346: E / Panel (8003): at aa.bb.cc.Panel.saveapp (Panel.java: 67)
09-12 07:30:34.346: E / Panel (8003): at aa.bb.cc.AndroidPaint.onOptionsItemSelected (AndroidPaint.java: 94)
09-12 07:30:34.346: E / Panel (8003): at android.app.Activity.onMenuItemSelected (Activity.java: 2170)
09-12 07:30:34.346: E / Panel (8003): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected (PhoneWindow.java: 730)
09-12 07:30:34.346: E / Panel (8003): at com.android.internal.view.menu.MenuItemImpl.invoke (MenuItemImpl.java: 139)
09-12 07:30:34.346: E / Panel (8003): at com.android.internal.view.menu.MenuBuilder.performItemAction (MenuBuilder.java: 855)
09-12 07:30:34.346: E / Panel (8003): at com.android.internal.view.menu.ExpandedMenuView.invokeItem (ExpandedMenuView.java: 89)
09-12 07:30:34.346: E / Panel (8003): at com.android.internal.view.menu.ExpandedMenuView.onItemClick (ExpandedMenuView.java: 93)
09-12 07:30:34.346: E / Panel (8003): at android.widget.AdapterView.performItemClick (AdapterView.java: 284)
09-12 07:30:34.346: E / Panel (8003): at android.widget.ListView.performItemClick (ListView.java: 3285)
09-12 07:30:34.346: E / Panel (8003): at android.widget.AbsListView $ PerformClick.run (AbsListView.java: 1640)
09-12 07:30:34.346: E / Panel (8003): at android.os.Handler.handleCallback (Handler.java: 587)
09-12 07:30:34.346: E / Panel (8003): at android.os.Handler.dispatchMessage (Handler.java: 92)
09-12 07:30:34.346: E / Panel (8003): at android.os.Looper.loop (Looper.java: 123)
09-12 07:30:34.346: E / Panel (8003): at android.app.ActivityThread.main (ActivityThread.java: 4363)
09-12 07:30:34.346: E / Panel (8003): at java.lang.reflect.Method.invokeNative (Native Method)
09-12 07:30:34.346: E / Panel (8003): at java.lang.reflect.Method.invoke (Method.java: 521)
09-12 07:30:34.346: E / Panel (8003): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java: 860)
09-12 07:30:34.346: E / Panel (8003): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 618)
09-12 07:30:34.346: E / Panel (8003): at dalvik.system.NativeStart.main (Native Method)
There is code:
private Bitmap mBitmap;
private Canvas mCanvas;
private Bitmap tmpBitmap;
private Canvas tmpCanvas;
private DrawHandler mDrawHandler;
private Canvas tCanvas;
private String mImagePath = Environment.getExternalStorageDirectory() + "/anppp";
private File file;
public void saveapp()
{
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat formatter= new SimpleDateFormat("yyyyMMMddHmmss");
String dateNow = formatter.format(currentDate.getTime());
file = new File(mImagePath + "/" + dateNow +".png");
FileOutputStream fos;
try {
file.createNewFile();
fos = new FileOutputStream(file);
tmpBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.close();
} catch (FileNotFoundException e) {
Log.e("Panel", "FileNotFoundException", e);
}
catch (IOException e) {
Log.e("Panel", "IOEception", e);
}
}
That's it .. I do not know what could be wrong ;(
© Stack Overflow or respective owner