0

I'm new in Android development and I have an app that saves a 'jogador' (player) record with some attributes (name, birthday...) and a photo.

When the user picks the image from gallery, I populate an ImageView with the photo so that the user can see it before he saves the record. (It's working here).

My problem is that I want to save that photo in a folder created by me (Inside res/ folder). eg: res/myFolder.

I don't know how I will access that folder to put an image inside. Follow my code bellow:

Bitmap bmp = BitmapFactory.decodeFile(fotoPath); //---> It works FileOutputStream fos; try { // 'fotos_jogador' is my folder inside res folder. // I think that 'Environment.getExternalStorageDirectory()' // gives me access to sdcard, but i don't want this, I want to save in a local app folder. File file = new File(Environment.getExternalStorageDirectory() + File.separator + "/fotos_jogador/" + ".png"); fos = new FileOutputStream(file); //I want do store a low quality image, just for contact photo. if(fos != null){ bmp.compress(CompressFormat.PNG, 20, fos); fos.close(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } 

Then, guys, my doubts:

  1. How can I give a custom name for my Image?

  2. How can I Save the image in my folder 'fotos_jogador'?

  3. How can I retrieve the Image after it's saved?

I appreciate the help. Thanks!

3
  • May be help this:stackoverflow.com/questions/16506594/… Commented May 17, 2013 at 18:59
  • Search your external storage for the hidden file ".png"!! Commented May 17, 2013 at 19:01
  • You can't because the /res folder is situated inside the apk file and can't be changed. Commented May 17, 2013 at 19:09

1 Answer 1

2

no you can not save anything in resource folder here is the link of duplicate post Is it possible to save image in assets folder from application you can save image in sd card or in internal memory.

Sign up to request clarification or add additional context in comments.

1 Comment

Right. What's the best way to do it? Can you help me? Thanks a lot!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.