Kiran_b
Kiran_b

Reputation: 363

How can i access data of one application in another application using Content Providers

I have two applications A and B, In application A suppose i am using ipdetails.db file and saving IP address in the iptable.

In Application A i am using Content Resolver(I used all methods provided in some examples of Content Provider) and other classes to access the data.

Now my question is In Application B i have transaction.db file with some tables how can i get ip details from application A using content providers.

Getting data from Content Providers with same application i succeeded how can i access data of One application in Another application.

I am waiting for your valuable inputs...

Upvotes: 1

Views: 707

Answers (1)

zetsin
zetsin

Reputation: 303

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> 

and 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); 

Upvotes: 1

Related Questions