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:
How can I give a custom name for my Image?
How can I Save the image in my folder 'fotos_jogador'?
How can I retrieve the Image after it's saved?
I appreciate the help. Thanks!
".png"!!