android how to open external file with my application

后端 未结 1 1078
死守一世寂寞
死守一世寂寞 2021-01-16 07:44

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

相关标签:
1条回答
  • 2021-01-16 08:12

    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

    0 讨论(0)
提交回复
热议问题