Back to project page Android-ORM.
The source code is released under:
Apache License
If you think the Android project Android-ORM listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * /*from w ww . ja v a2 s. c o m*/ */ package cn.ieclipse.aorm.example; import android.content.ContentProvider; import android.content.ContentValues; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.net.Uri; import cn.ieclipse.aorm.Session; /** * @author Jamling * */ public class ExampleContentProvider extends ContentProvider { public static final String AUTH = "cn.ieclipse.aorm.example.provider"; public static final Uri URI = Uri.parse("content://" + AUTH); private SQLiteOpenHelper mOpenHelper; private static Session session; /* * (non-Javadoc) * * @see android.content.ContentProvider#delete(android.net.Uri, * java.lang.String, java.lang.String[]) */ @Override public int delete(Uri arg0, String arg1, String[] arg2) { // TODO Auto-generated method stub return 0; } /* * (non-Javadoc) * * @see android.content.ContentProvider#getType(android.net.Uri) */ @Override public String getType(Uri arg0) { // TODO Auto-generated method stub return null; } /* * (non-Javadoc) * * @see android.content.ContentProvider#insert(android.net.Uri, * android.content.ContentValues) */ @Override public Uri insert(Uri arg0, ContentValues arg1) { // TODO Auto-generated method stub return null; } /* * (non-Javadoc) * * @see android.content.ContentProvider#query(android.net.Uri, * java.lang.String[], java.lang.String, java.lang.String[], * java.lang.String) */ @Override public Cursor query(Uri arg0, String[] arg1, String arg2, String[] arg3, String arg4) { // TODO Auto-generated method stub return null; } /* * (non-Javadoc) * * @see android.content.ContentProvider#update(android.net.Uri, * android.content.ContentValues, java.lang.String, java.lang.String[]) */ @Override public int update(Uri arg0, ContentValues arg1, String arg2, String[] arg3) { // TODO Auto-generated method stub return 0; } public static Session getSession() { return session; } /* * (non-Javadoc) * * @see android.content.ContentProvider#onCreate() */ @Override public boolean onCreate() { mOpenHelper = new SQLiteOpenHelper(this.getContext(), "example.db", null, 1) { public void onCreate(SQLiteDatabase db) { String sql = ""; sql = "create TABLE grade ( "; sql += "_id Integer Primary key autoincrement, "; sql += "_sid Integer, "; sql += "_cid Integer, "; sql += "_score Float)"; db.execSQL(sql); sql = "create TABLE student ( "; sql += "_id Integer Primary key autoincrement, "; sql += "_name String, "; sql += "_age Integer, "; sql += "_phone String)"; db.execSQL(sql); sql = "create TABLE course ( "; sql += "_id Integer Primary key autoincrement, "; sql += "_name String)"; db.execSQL(sql); } public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } }; session = new Session(mOpenHelper, getContext().getContentResolver()); return true; } }