1. Download our Official Android App: Forums for Android!

Apps save an bitmap

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

  1. Elprisionero

    Elprisionero Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Nov 11, 2010

    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...