2012-10-19 94 views
1

我有兩個應用程序A和B我訪問一個應用程序的數據在另一個應用程序,在應用程序A假設我使用ipdetails.db文件並保存在iptable的IP地址。如何使用內容提供商

在應用程序A我使用內容解析器(I應用於內容提供者的一些實施例提供的所有方法)和其他類訪問數據。

現在我的問題是,在應用程序B我有transaction.db一些表我如何使用內容提供商得到應用一個IP詳細文件。

從具有相同應用程序的內容提供程序獲取數據我成功瞭如何在另一個應用程序中訪問One應用程序的數據。

我在等待着您的寶貴意見......

回答

1

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"); 
    } 

ProjectTwo:

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); 
+0

如果我使用上面的代碼項目一個不推出,如果你不介意的話,你可以請我更新indetail –

+0

發表您的主代碼這裏?? – zetsin