Image Not Saving In Folder
I am trying to create a folder and save images in it. But it's not working. I don't know what's wrong in my code - can you tell me why? // The method that invoke of uploading
Solution 1:
How I do make the folder in DCIM and create a file there into:
/*
Create a path where we will place our picture in the user's public
pictures directory. Note that you should be careful about what you
place here, since the user often manages these files.
For pictures and other media owned by the application, consider
Context.getExternalMediaDir().
*/finalFilepath=
Environment.getExternalStoragePublicDirectory
(
//Environment.DIRECTORY_PICTURES//Environment.DIRECTORY_DCIM
Environment.DIRECTORY_DCIM + "/MyFolderName/"
);
// Make sure the Pictures directory exists.if(!path.exists())
{
path.mkdirs();
}
finalFilefile=newFile(path, fileJPG + ".jpg");
try
{
finalFileOutputStreamfos=newFileOutputStream(file);
finalBufferedOutputStreambos=newBufferedOutputStream(fos, 8192);
//bmp.compress(CompressFormat.JPEG, 100, bos);
bmp.compress(CompressFormat.JPEG, 85, bos);
bos.flush();
bos.close();
}
catch (final IOException e)
{
e.printStackTrace();
}
fileJPG
is the file name I'm creating (dynamically, adding a date).
Replace MyFolderName
with albumName
.
bmp
is my Bitmap data (a screenshot, in my case).
Post a Comment for "Image Not Saving In Folder"