1. Check out our app, Forums for Android! Download and leave feedback here!

save an bitmap

Discussion in 'Application Development' started by Elprisionero, Nov 18, 2010.

  1. Elprisionero

    Elprisionero New Member
    Thread Starter
    5

    Nov 11, 2010
    2
    0
    5
    Hi

    so I have this code.

    public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.save_sign:

    myView.save();
    break;
    }
    return false;



    }


    public void save() {
    String filename;
    Date date = new Date(0);
    SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMMddHHmmss");
    filename = sdf.format(date);



    try{


    String path = Environment.getExternalStorageDirectory().toString();
    OutputStream fOut = null;
    File file = new File(path, "/DCIM/Signatures/"+filename+".jpg");
    fOut = new FileOutputStream(file);

    mBitmap.compress(Bitmap.CompressFormat.JPEG, 85, fOut);
    fOut.flush();
    fOut.close();

    MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    But I cant save the image anyway. What im doing wrong?
     

    Advertisement

Share This Page

Loading...