[ create a new paste ] login | about

Link: http://codepad.org/Rx00HjHd    [ raw code | fork ]

Plain Text, pasted on Sep 18:
package my.package.provider;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.net.Uri;

public class CountryContentProvider extends ContentProvider {

    private static final String TABLE_NAME = "countries";
    public static final String PROVIDER = "my.package.provider.countrycontentprovider";
	public static final Uri CONTENT_URI = Uri.parse("content://" + PROVIDER + "/country");
    private static final UriMatcher uriMatcher;

    private static final int COUNTRY = 1;

    static {
        uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
        uriMatcher.addURI(PROVIDER, TABLE_NAME, COUNTRY);
    }
	
	@Override
	public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; }

	@Override
	public String getType(Uri uri) { return null; }

	@Override
	public Uri insert(Uri uri, ContentValues values) { return null; }

	@Override
	public boolean onCreate() { return true; }

	@Override
	public Cursor query(Uri uri, String[] projection, String selection,	String[] selectionArgs, String sortOrder) { return null;  }

	@Override
	public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; }
}


// from my activity
    	ContentResolver resolver = getContentResolver();
    	Cursor c = resolver.query(CountryContentProvider.CONTENT_URI, null, null, null, null);
    	if (c == null){
    		Log.i("MainActivity", "no cursor returned");
    	}
    	else{
    		Log.i("MainActivity", "found a cursor");
    	}
		
		
// AndroidManifest.xml
    <provider
        android:name="my.package.provider.CountryContentProvider"
        android:authorities="my.package.provider.countrycontentprovider" />


Create a new paste based on this one


Comments: