Android如何使用我的应用程序打开外部文件 [英] android how to open external file with my application

查看:602
本文介绍了Android如何使用我的应用程序打开外部文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个可与sqlite数据库配合使用的应用程序,并且在菜单中完成了一个工具,可通过短信,邮件,whatsapp等将数据库传递给其他移动设备. 当我在另一台手机上拥有数据库时,单击会出现一条消息,提示:没有应用程序可以执行此任务. 如果我必须在清单中放入一些东西来识别文件,或者想知道在哪里可以找到有关此信息的某种想法,我想知道如何使用我的应用程序打开该数据库.

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.

推荐答案

如果您想让您的应用识别特定文件,则需要在清单中的活动标签之一内使用意图过滤器. 例如,要使用您的应用打开pdf文件,您需要使用:

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>

在您使用sqlite数据库文件的情况下,它可以是.sqlite,.db-这取决于您如何命名.

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

有关数据意图过滤器的更多详细信息: http://developer.android.com/guide/topics/manifest/data -element.html

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

这篇关于Android如何使用我的应用程序打开外部文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆