android how to open external file with my application

拟墨画扇 提交于 2019-12-19 11:33:19

问题


I have made an app that works with an sqlite database, and I have done a tool in my menu to pass the database by sms, mail, whatsapp, etc... to other mobile. When I have the database in the other mobile when I do click appears a message saying: no application can perform this task. I'd like to know how I can open this database with my app, if I have to put something in manifest for recognize files or some idea to know where I find information about this.


回答1:


If you want want your app to recognize specific files, you need to use intent filter inside one of your activity tags in manifest. For example, to open pdf file with your app you need to use:

<activity android:name=".ActivityThatKnowsHowToHandlePDFFiles">

        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="file" />
        <data android:mimeType="*/*" />
        <data android:pathPattern=".*\\.pdf" />

</activity>

In your case with sqlite database file it can be .sqlite, .db - it depends on how did you name it.

More details on data intent filter: http://developer.android.com/guide/topics/manifest/data-element.html



来源:https://stackoverflow.com/questions/17029001/android-how-to-open-external-file-with-my-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!