Intent Filter giving file path that does not exist

I’m creating an app that has to recive a txt file from WhatsApp export chat function.

I have done this with an intent filter, and i get a path “content:/ I get it as a file, and when i try to read it, its not there. It gives a FileNotFound exception.

This is the intent filter

<activity android:name="">
                <action android:name="android.intent.action.SEND"/>
                <action android:name="android.intent.action.SEND_MULTIPLE"/>
                <category android:name="android.intent.category.APP_EMAIL"/>
                <category android:name="android.intent.category.APP_MESSAGING"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data android:mimeType="text/*" />

This is the onCreate function that is called when someone calls the intent-filter from whatsapp

    protected void onCreate(Bundle savedInstanceState) {
        TextView text = findViewById(;
        TextView text2 = findViewById(;
        Intent intent = getIntent();
        String action = intent.getAction();
        String type = intent.getType();
        Bundle bundle = intent.getExtras();
        ArrayList a = (ArrayList) bundle.get(Intent.EXTRA_STREAM);
        Uri uri = (Uri) a.get(0);
        File file = new File(uri.toString());

I have been checking other apps that use intent filters and the file path should have this format: “content://”
I know this because i tried to send the exported chat through whatsapp and thats the url where it is saved.
I don’t know if the problem is with the intent filter or with how im reading the intent that is recived.

Leave a Reply

1 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
newest oldest most voted
Notify of

and i get a path “content:/

That is a Uri. Specifically, it is one from a ContentProvider.

I get it as a file

It is not a file. It is a Uri.

Use ContentResolver and openInputStream() to read in the content associated with that Uri.