Vincent
Vincent

Reputation: 1033

Copy a file from another app

I associated my app with a file extension .vv using this code:

         <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:mimeType="application/*" />
            <data android:pathPattern=".*\\.vv" />
            <data android:host="*" />
        </intent-filter>

Now when I open a file from DropBox for example, my app get launched and I can get the full path of the source file using:

this.getIntent().getData().getPath()

However when I try to read or copy it in any way (directly from path, or from the uri using getContentResolver().openInputStream(uri), I have an EACCES exception on the source file. I don't have this exception when I open it from the GMail app, but from DropBox I get it.

How can I read/copy it then ?

Upvotes: 2

Views: 151

Answers (1)

Karim Baidar
Karim Baidar

Reputation: 559

Use "Uses permission write external storage"

<application>
    ...

</application>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>
The uses-permission tag needs to be outside the application tag.

Upvotes: 1

Related Questions