Back to project page tb-android-3.
The source code is released under:
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> Everyone is permitted to copy and distribute verba...
If you think the Android project tb-android-3 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.gordon.tb3.provider; // w w w.ja v a2 s .co m import android.content.ContentProvider; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.net.Uri; public abstract class CustomContentProvider extends ContentProvider { protected static final String AUTHORITY = "gordon"; protected static CoreDatabase mDB; @Override public boolean onCreate() { if (mDB == null) { mDB = new CoreDatabase(getContext()); } return true; } @Override public abstract int delete(Uri uri, String selection, String[] selectionArgs); @Override public abstract String getType(Uri uri); @Override public abstract Uri insert(Uri uri, ContentValues values); @Override public abstract Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder); /** * Classe d'aide l'accs la base de donnes. * * @author romain * */ protected static class CoreDatabase extends SQLiteOpenHelper { private static final int DB_VERSION = 1; private static final String DB_NAME = "gordon.db"; public CoreDatabase(Context context) { super(context, DB_NAME, null, DB_VERSION); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE gordon (_id INTEGER PRIMARY KEY, name TEXT);"); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DELETE FROM gordon;"); } } }