File publicAppDir = getExternalFilesDir(android.os.Environment.DIRECTORY_DOCUMENTS);
File targetFile = new File(publicAppDir, "my_app_file.txt");
try (FileOutputStream fos = new FileOutputStream(targetFile)) {
String textData = "This is text saved inside the app-specific external folder.";
fos.write(textData.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
Sentry.configureScope(scope -> {
Attachment attachment = new Attachment(targetFile.getAbsolutePath());
scope.addAttachment(attachment);
});
Integration
sentry-android
Build System
Gradle
AGP Version
8.14.0
Proguard
Enabled
Other Error Monitoring Solution
No
Version
8.41.0+
Steps to Reproduce
Expected Result
Attachment is present in ANR report
Actual Result
No attachments