Reputation: 5101
I am trying to store images to a specific folder in the device.
This is the code to store an image:
private static final String IMAGE_DIRECTORY = "/capenergy_camera";
private void saveImage() {
if (requestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
showLoading("Saving...");
File file = new File(Environment.getExternalStorageDirectory()+IMAGE_DIRECTORY
+ File.separator + ""
+ System.currentTimeMillis() + ".png");
try {
file.createNewFile();
SaveSettings saveSettings = new SaveSettings.Builder()
.setClearViewsEnabled(true)
.setTransparencyEnabled(true)
.build();
mPhotoEditor.saveAsFile(file.getAbsolutePath(), saveSettings, new PhotoEditor.OnSaveListener() {
@Override
public void onSuccess(@NonNull String imagePath) {
hideLoading();
showSnackbar("Image Saved Successfully");
mPhotoEditorView.getSource().setImageURI(Uri.fromFile(new File(imagePath)));
}
@Override
public void onFailure(@NonNull Exception exception) {
hideLoading();
showSnackbar("Failed to save Image");
}
});
} catch (IOException e) {
e.printStackTrace();
hideLoading();
showSnackbar(e.getMessage());
}
}
}
I don´t know why the storage folder is always adding the path /emulated/0, and I don´t know how to access that folder.
Example: /storage/emulated/0/capenergy_camera/1565010745877.png
Upvotes: 0
Views: 55
Reputation: 1006944
I don´t know why the storage folder is always adding the path /emulated/0
In the device filesystem on your device, /storage/emulated/0
is the root of what the Android SDK refers to as external storage. This is a fairly typical setup.
I don´t know how to access that folder
Use the Device File Explorer in Android Studio.
Or, use adb shell
.
Or, plug the device into your development machine via a USB cable and mount what users refer to as "internal storage" (though it is really what the SDK refers to as external storage). Your file will not show up here right away, though, as it is not indexed by the MediaStore
. Use MediaScannerConnection.scanFile()
to get it indexed more quickly.
Or, use some on-device file manager, if you have one installed.
Upvotes: 1