Monday 29 June 2015

Create folder structure for save image into internal memory

public String saveToInternalSorage(Bitmap bitmapImage, String folderPath,
String filename) {
File directory = getActivity().getDir("images", Context.MODE_PRIVATE);
directory = new File(directory, folderPath);
if (!directory.isDirectory())
directory.mkdirs();
File mypath = new File(directory, filename);
try {
FileOutputStream fos = new FileOutputStream(mypath);
bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
return mypath.getAbsolutePath();
}

No comments:

Post a Comment