Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 访问内容提供商_Android_Sql_Provider - Fatal编程技术网

Android 访问内容提供商

Android 访问内容提供商,android,sql,provider,Android,Sql,Provider,如果我在应用程序a中有一个内容提供者和内容URI,它也在清单中。如何从应用程序B调用它 我是否需要在保存sqlite数据库的类中编写代码?或者我需要创建一个全新的类并从那里调用提供者 Thanx。根据URI的性质,您可以注册活动B以接受URI 为此,您将以下“意图文件管理器”部分添加到AndroidManifest.xml中的活动B中 <activity android:name="ACTIVITY B PATH"> <intent-filter>

如果我在应用程序a中有一个内容提供者和内容URI,它也在清单中。如何从应用程序B调用它

我是否需要在保存sqlite数据库的类中编写代码?或者我需要创建一个全新的类并从那里调用提供者


Thanx。根据URI的性质,您可以注册活动B以接受URI

为此,您将以下“意图文件管理器”部分添加到AndroidManifest.xml中的活动B中

    <activity android:name="ACTIVITY B PATH">
        <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="THE MIME TYPE TO ACCEPT" />
       </intent-filter>
    </activity>
活动B将自动激活,您可以通过从onCreate()方法调用getIntent().getData()来读取URI

您可以选择最适合您需要的不同操作(查看、编辑、插入…)和数据类型(MIME、架构、路径…)。

可能重复
 Intent intent = new Intent(Intent.ACTION_VIEW);
 intent.setData(Uri.parse(CONTENT_URI)); 
 activity.startActivity(intent);