I wrote an app that uses Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES) to find the folder to store images to. I then write the jpg to that folder and then use the following code to allow the user to email, SMS, Facebook ... or whatever apps their phone has setup.
Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setType("image/jpg");
File shareImg = new File(fileName);
i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(shareImg));
startActivity(i);
This code works fine on the devices I tested on. Now I am finding that users that do not have an SD card are not able to use this code. So I decided to try and write the image to internal memory. I was able to write the image to my apps folder and set the access as Context.MODE_WORLD_READABLE but when I fire off the intent, GMail, SMS, or any of the other maps just give me a message that they are unable to attach the image. I thought the problem might be that the image wasn't in the actual "pictures" folder of the device but I couldn't find an routing equivalent to Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES) for internal storage. Has anyone else been able to do something like this?
I was able to solve this by changing my code to use:
getExternalFilesDir(Environment.DIRECTORY_PICTURES)
instead of:
Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES)