good morning everyone
I have this code in my app, it is to receive a file from another application through the share button. And here, no problem.
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
if (type.startsWith("video/")) {
Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
String path = imageUri.getPath();
// /item/4567592 --> whatsapp
// /media/telegram/telegram docuemnts/name.mp4 --> telegram
// no more apps tested
}
}
The question is that I want the absolute absolute path of the file, yes, I do not want to use a File, or anything else, I want the actual path of the file on the device.
I have tried 1000 things, also the solutions with the Cursor, but they return null, or other puzzling errors.
I tried to save the file in the internal memory or in the cache of the app, but I did not get it either.
Suggestions? Thank you!
I want the absolute absolute path of the file.
You should not want that. There is no reason for it as long as you do not have to supply the 'path' to an external library.
Just open an InputStream
. Read from the stream and save to file.
InputStream is = getContentResolver().openInputStream(imageUri);
You can use the input stream as if it was the file input stream.