Click here to Skip to main content
11,716,285 members (87,627 online)
Click here to Skip to main content
Add your own
alternative version

Using Cursor Loader in Android

, 9 Oct 2014 CPOL 68.8K 1.6K 16
The article helps in understanding the use of Cursor Loader in Android.
CustomCursorLoader.zip
CustomCursorLoader
.classpath
.project
.settings
org.eclipse.jdt.core.prefs
assets
bin
gen
tpg
main
ic_launcher-web.png
libs
android-support-v4.jar
project.properties
res
drawable-hdpi
ic_launcher.png
drawable-ldpi
ic_launcher.png
drawable-mdpi
ic_launcher.png
drawable-xhdpi
ic_launcher.png
layout
values
values-v11
values-v14
src
tpg
database
main
package tpg.database;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.util.Log;

public class DatabaseAccessUtility extends ContentProvider 
{
	// The Android's default system path of your application database.
	protected static String DB_NAME = "SampleCursorLoader.db";	
	protected static final int DB_VERSION = 1;
	DatabaseHandler dbHandler;
	public static String authority="tpg.database.provider";
	public static Uri CONTENT_URI = Uri.parse("content://" + authority  + "/SampleCursorLoader");
	private static String TAG="DatabaseAccessUtility";
	   
	@Override
	public boolean onCreate() {
		Log.v(TAG,"DatabaseAccessUtility:OnCreate()");
		if(dbHandler == null)
			dbHandler = new DatabaseHandler(getContext(), DB_NAME, null, DB_VERSION);
		if(dbHandler==null)
			return false;
		dbHandler.insert();
		return true;
	}
	@Override
	public Cursor query(Uri uri, String[] projection, String selection,
			String[] selectionArgs, String sortOrder) {
		Log.v(TAG,"DatabaseAccessUtility:Query()");
		Cursor cursor=dbHandler.queryData();
		return cursor;
	}

	@Override
	public int delete(Uri arg0, String arg1, String[] arg2) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String getType(Uri uri) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Uri insert(Uri uri, ContentValues values) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int update(Uri uri, ContentValues values, String selection,
			String[] selectionArgs) {
		// TODO Auto-generated method stub
		return 0;
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Khushboo Kaur
Software Developer 3Pillar Global, Inc
India India
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150901.1 | Last Updated 9 Oct 2014
Article Copyright 2013 by Khushboo Kaur
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid