0

I have an app that needs to send multiple image attachments in an email. To send the images, I need an absolute path. For this, I use functions .toAbsolutePath and Paths.get from java.nio. Both of these functions only work with API 26 and higher. They seem to me like really basic functions, so I don't know why they don't support lower APIs. Is there any way to make them work with lower APIs?

realPath1 = Paths.get("storage/emulated/0/Android/data/com.example.abbmalfunctionreport/cache/$image1").toAbsolutePath()
Anas Mehar
  • 2,739
  • 14
  • 25

1 Answers1

1

File.getAbsolutePath() is available since API-1.

You should probably use Environment class also, see How to get absolute path of Internal Storage in Android

shkschneider
  • 17,833
  • 13
  • 59
  • 112
  • File.getAbsolutePath() is not working for me. I can't explain why, but it is stuck at sending the email. I think the output is different than from the code before. – tweakingmango Aug 06 '19 at 10:16
  • What you pass to `Paths.get()` is already hard-coded absolute. Use `Environment` and `File.getAbsolutePath()` to get what you want. I works :) – shkschneider Aug 06 '19 at 12:59