Android How do you save an image with your own unique Image Name?

Posted by Usmaan on Stack Overflow See other posts from Stack Overflow or by Usmaan
Published on 2011-02-07T15:15:26Z Indexed on 2011/02/07 15:25 UTC
Read the original article Hit count: 188

Filed under:
|

This sounds like a issue a beginner like me would only have...this is my code...

    private void saveAvatar(Bitmap avatar) {
    String strAvatarFilename =  Id + ".jpg"; 
    try {
        avatar.compress(CompressFormat.JPEG, 100, openFileOutput(strAvatarFilename, MODE_PRIVATE));
    } catch (Exception e) {
        Log.e(DEBUG_TAG, "Avatar compression and save failed.", e);
    }
    Uri imageUriToSaveCameraImageTo = Uri.fromFile(new File(PhotoActivity.this.getFilesDir(), strAvatarFilename));
    Editor editor = Preferences.edit();
    editor.putString(PREFERENCES_AVATAR, imageUriToSaveCameraImageTo.getPath());
    editor.commit();
    ImageButton avatarButton = (ImageButton) findViewById(R.id.ImageButton_Avatar);
    String strAvatarUri = Preferences.getString(PREFERENCES_AVATAR, "");
    Uri imageUri = Uri.parse(strAvatarUri);
    avatarButton.setImageURI(null); 
    avatarButton.setImageURI(imageUri);
}

This does save the image but when i go to look at the image on the sd card ti is called imag001 etc not the ID i am labelling it. How do i save the image with a name i want to call it? regards

© Stack Overflow or respective owner

Related posts about android

Related posts about image