save an bitmap


Last Updated:

  1. Elprisionero

    Elprisionero New Member This Topic's Starter

    Joined:
    Nov 11, 2010
    Messages:
    2
    Likes Received:
    0
    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...