Android Open Source - sqlite-provider Logged Content Provider

From Project

Back to project page sqlite-provider.


The source code is released under:

Apache License

If you think the Android project sqlite-provider listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package novoda.lib.sqliteprovider.provider;
//from w  w w  . ja v a2s .  co  m
import novoda.lib.sqliteprovider.cursor.EmptyCursor;
import novoda.lib.sqliteprovider.util.Log;
import novoda.lib.sqliteprovider.util.Log.ContentProvider.CPType;

import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.database.Cursor;

public class LoggedContentProvider extends ContentProvider {

    private String logTag = null;

    public int delete(Uri uri, String selection, String[] selectionArgs) {
        Log.ContentProvider.log(CPType.DELETE, logTag, uri, selectionArgs, selection,
                selectionArgs, null, null);
        return 1;

    public String getType(Uri uri) {
        Log.ContentProvider.log(CPType.GET_TYPE, logTag, uri, null, null, null, null, null);
        return "logged/uri+" + uri;

    public Uri insert(Uri uri, ContentValues values) {
        Log.ContentProvider.log(CPType.INSERT, logTag, uri, null, null, null, null, values);
        return ContentUris.withAppendedId(uri, 1);

    public boolean onCreate() {
        if (getLogTag() == null) {
        return true;

    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
            String sortOrder) {
        Log.ContentProvider.log(CPType.QUERY, logTag, uri, projection, selection, selectionArgs,
                sortOrder, null);
        return new EmptyCursor();

    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
        Log.ContentProvider.log(CPType.QUERY, logTag, uri, null, selection, selectionArgs, null,
        return 1;

    public void setLogTag(String logTag) {
        this.logTag = logTag;

    public String getLogTag() {
        return logTag;

Java Source Code List