Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
549 views
in Technique[技术] by (71.8m points)

android how to open external file with my application

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...