在用Content Provider時,通常會使用到一個class(使用者自訂)去extends SQLiteOpenHelper 其中會需要override public void onCreate(SQLiteDatabase db) 這個onCreate(SQLiteDatabase db)如果要被呼叫到 通常都是有使用到 SQLiteOpenHelper裡的getWritableDatabase() 程式會檢查有無db,沒有就會呼叫此onCreate( SQLiteDatabase db ) function! 例子 : package com.android.GSensorActivity; 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.SQLiteQueryBuilder; import android.database.sqlite.SQLiteOpenHelper; import android.net.Uri; import android.util.Log; public class sensorProvider extends ContentProvider { public interface SensorSchema { String TABLE_NAME="SensorData"; String ORDER = "_order"; String DELTA = "delta"; String TIME = "time"; } private static class DatabaseHelper extends SQLiteOpenHelper { private ...