hello i\'m trying to save pictures taken on my application, but when i try to access the memory to place the data, an error comes out
unable to decode stream java.io
You need to write to external storage, make sure you added the permission:
...
Checks if external storage is available for read and write:
public boolean isExternalStorageWritable() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
return true;
}
return false;
}
Use the root of the public directory instead of using the root of Android.
If you want to save public files on the external storage, use the getExternalStoragePublicDirectory()
public File getAlbumStorageDir(String albumName) {
// Get the directory for the user's public pictures directory.
File file = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DCIM), albumName);
if (!file.mkdirs()) {
Log.e(LOG_TAG, "Directory not created");
}
return file;
}
If you want to save files that are private to your app, use the getExternalFilesDir()
public File getAlbumStorageDir(Context context, String albumName) {
// Get the directory for the app's private pictures directory.
File file = new File(context.getExternalFilesDir(
Environment.DIRECTORY_DCIM), albumName);
if (!file.mkdirs()) {
Log.e(LOG_TAG, "Directory not created");
}
return file;
}
More information on the link http://developer.android.com/training/basics/data-storage/files.html