![](/img/trans.png)
[英]How to access one App's Database to another Application using Sqlite?
[英]How can i access data of one application in another application using Content Providers
我有兩個應用程序A和B,在應用程序A中,假設我正在使用ipdetails.db文件並將IP地址保存在iptable中。
在應用程序A中,我正在使用Content Resolver(我使用了Content Provider的某些示例中提供的所有方法)和其他類來訪問數據。
現在我的問題是在應用程序B中,我有帶有一些表的transaction.db文件,如何使用內容提供者從應用程序A獲取IP詳細信息。
從具有相同應用程序的內容提供者獲取數據,我成功了如何在另一個應用程序中訪問一個應用程序的數據。
我正在等待您的寶貴意見...
ProjectOne:
AndroidManifest.xml:
<activity
android:name=".ProjectTwoActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.zetsin.test.MYACTION" />
<data android:scheme="info"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
和MainActivityInProjectOne.java
// getIntent().getData() is get the url form ProjectTwo
if (getIntent().getData() != null) {
// get the data passed from ProjectTwo
String value = getIntent().getExtras().getString("value");
}
項目二:
MainActivityInProjectTwo.java
// start the activity in ProjectOne by Action and URI, then pass the data.
Uri uri = Uri.parse("info://test");
Intent invokeIntent = new Intent("com.zetsin.test.MYACTION",uri);
invokeIntent.putExtra("value", "Data from project Two");
startActivity(invokeIntent);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.