亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

annuaire recherche
android Manifest Manifest.permission Manifest.permission_group android.accessibilityservice AccessibilityService android.accounts Account android.app NotificationManager android.bluetooth BluetoothAdapter BluetoothClass BluetoothClass.Device BluetoothClass.Device.Major BluetoothClass.Service BluetoothDevice BluetoothServerSocket BluetoothSocket android.content SharedPreferences android.database.sqlite SQLiteCursorDriver SQLiteOpenHelper android.graphics Bitmap android.location LocationListener Geocoder GpsStatus GpsStatus.Listener GpsStatus.NmeaListener GpsSatellite android.media AudioFormat AsyncPlayer AudioRecord AudioRecord.OnRecordPositionUpdateListener ThumbnailUtils AudioManager android.net TrafficStats MailTo LocalSocket android.os AsyncTask AsyncTask.Status CountDownTimer Message MessageQueue HandlerThread android.text Html android.util JsonWriter android.view ContextMenu ContextMenu.ContextMenuInfo Display ViewManager View ViewStub ViewTreeObserver ViewParent WindowManager GestureDetector Gravity MenuInflater ScaleGestureDetector SoundEffectConstants android.view.inputmethod InputConnection InputMethod InputMethodSession BaseInputConnection InputMethodManager android.widget AbsListView AbsListView.LayoutParams AbsListView.OnScrollListener AbsListView.RecyclerListener AbsoluteLayout AbsoluteLayout.LayoutParams AbsSeekBar AbsSpinner AdapterView AdapterView.AdapterContextMenuInfo AdapterView.OnItemLongClickListener AdapterView.OnItemSelectedListener AdapterView.OnItemClickListener AnalogClock BaseAdapter BaseExpandableListAdapter Button CheckBox CheckedTextView Checkable Chronometer Chronometer.OnChronometerTickListener CompoundButton CompoundButton.OnCheckedChangeListener CursorAdapter CursorTreeAdapter DatePicker DatePicker.OnDateChangedListener DialerFilter DigitalClock EditText Filter Filter.FilterListener Filter.FilterResults ExpandableListAdapter ExpandableListView.OnChildClickListener ExpandableListView.OnGroupClickListener ExpandableListView.OnGroupCollapseListener ExpandableListView.OnGroupExpandListener Filterable Gallery Gallery.LayoutParams GridView GridLayout GridLayout.Alignment RadioGroup ImageView ImageView.ScaleType HorizontalScrollView ImageButton ImageSwitcher FilterQueryProvider ListAdapter ListView MediaController MultiAutoCompleteTextView MultiAutoCompleteTextView.CommaTokenizer MultiAutoCompleteTextView.Tokenizer QuickContactBadge RadioButton RatingBar RatingBar.OnRatingBarChangeListener RelativeLayout RemoteViews ResourceCursorAdapter ResourceCursorTreeAdapter Scroller ScrollView SearchView SearchView.OnCloseListener SearchView.OnQueryTextListener SearchView.OnSuggestionListener SeekBar SeekBar.OnSeekBarChangeListener SimpleAdapter SimpleAdapter.ViewBinder SimpleCursorAdapter SimpleCursorAdapter.CursorToStringConverter SimpleCursorAdapter.ViewBinder SimpleCursorTreeAdapter SimpleCursorTreeAdapter.ViewBinder SimpleExpandableListAdapter SlidingDrawer SlidingDrawer.OnDrawerCloseListener SlidingDrawer.OnDrawerOpenListener SlidingDrawer.OnDrawerScrollListener Spinner SpinnerAdapter WrapperListAdapter TabHost TabHost.TabSpec TextView TimePicker TimePicker.OnTimeChangedListener Toast TableLayout TableLayout.LayoutParams TableRow TableRow.LayoutParams TabWidget TextSwitcher ToggleButton TwoLineListItem VideoView ViewAnimator ViewFlipper ViewSwitcher ViewSwitcher.ViewFactory ZoomButtonsController ZoomButtonsController.OnZoomListener ZoomButton ZoomControls dalvik.system DexFile
personnages


SQLiteOpenHelper

版本:Android 4.0 r1

結(jié)構(gòu)

繼承關(guān)系

public abstract class SQLiteOpenHelper extends Object

java.lang.Object

android.database.sqlite.SQLiteOpenHelper

類概述

一個幫助類,幫助創(chuàng)建數(shù)據(jù)庫和數(shù)據(jù)庫版本管理。

使用必須創(chuàng)建一個子類來實現(xiàn)其onCreate(SQLiteDatabase), onUpgrade(SQLiteDatabase, int, int)方法,同時任意實現(xiàn)onOpen(SQLiteDatabase)方法,同時打開數(shù)據(jù)庫操作必須保證數(shù)據(jù)庫存在,如果不存在則創(chuàng)建它,并且對其必要的升級,維護其保持一個最佳的狀態(tài)。

使用本類提供內(nèi)容開始創(chuàng)建數(shù)據(jù)庫是非常容易的,首先必須對數(shù)據(jù)庫進行升級,以避免在數(shù)據(jù)庫啟動后長期使用而阻塞數(shù)據(jù)。

舉個例子,在NotePad的例子程序中參看類NotePadProvider,在SDK的目錄samples/下面。

注意這個類假定升級的版本號是單調(diào)遞增的。

構(gòu)造函數(shù)

public SQLiteOpenHelper (Context context, String name, SQLiteDatabase.CursorFactory factory, int version)

創(chuàng)建一個幫助對象,打開或者管理數(shù)據(jù)庫。該方法通??焖俜祷?。數(shù)據(jù)庫并沒有實際創(chuàng)建或打開,直到getWritableDatabase() getReadableDatabase()其中一個被調(diào)用。

參數(shù)

context 用來打開或創(chuàng)建數(shù)據(jù)庫

name 數(shù)據(jù)庫文件名,對一個在內(nèi)存中的數(shù)據(jù)庫而言是null

factory 用來創(chuàng)建對象游標(biāo),或者默認(rèn)為null

version 數(shù)據(jù)庫的序號(1開始);如果數(shù)據(jù)庫是舊的,onUpgrade(SQLiteDataBase,int,int)會被調(diào)用去升級數(shù)據(jù)庫;如果數(shù)據(jù)庫是新的,onDowngrade(SQLiteDatabase,int,int)會被調(diào)用去降級數(shù)據(jù)庫。

public SQLiteOpenHelper (Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler)

創(chuàng)建一個幫助對象,打開或者管理數(shù)據(jù)庫。該方法通常快速返回。數(shù)據(jù)庫并沒有實際創(chuàng)建或打開,直到getWritableDatabase() getReadableDatabase()其中一個被調(diào)用。

參數(shù)

context 用來打開或創(chuàng)建數(shù)據(jù)庫

name 數(shù)據(jù)庫文件名,對一個在內(nèi)存中的數(shù)據(jù)庫而言是null

factory 用來創(chuàng)建對象游標(biāo),或者默認(rèn)為null

version 數(shù)據(jù)庫的序號(1開始);如果數(shù)據(jù)庫是舊的,onUpgrade(SQLiteDataBase,intint)會被調(diào)用去升級數(shù)據(jù)庫;如果數(shù)據(jù)庫是新的,onDowngrade(SQLiteDatabase,intint)會被調(diào)用去降級數(shù)據(jù)庫。

errorHandler 當(dāng)sqlite報告一個數(shù)據(jù)庫毀壞錯誤時,DatabaseErrorHandler會被使用。

公共方法

public synchronized void close ()

關(guān)閉任何打開的數(shù)據(jù)庫對象。

public String getDatabaseName ()

返回正被打開的通過構(gòu)造函數(shù)傳遞進來的SQLite數(shù)據(jù)庫的名字。

public synchronized SQLiteDatabase getReadableDatabase ()

創(chuàng)建或打開一個數(shù)據(jù)庫。這和getWritableDatabase()返回的對象是同一個,除非一些因素要求數(shù)據(jù)庫只能以read-only的方式被打開,比如磁盤滿了。在這種情況下,一個只讀的數(shù)據(jù)庫對象將被返回。如果這個問題被修改掉,將來調(diào)用getWritableDatabase()就可能成功,而這時read-only數(shù)據(jù)庫對象將被關(guān)閉,并且讀寫對象將被返回。

getWritableDatabase(),這個方法需要很長時間才返回,所以你不該在應(yīng)用程序的主線程中調(diào)用它,包括方法ContentProvider.onCreate()。

返回值

一個有效的數(shù)據(jù)庫對象,直到getWritableDatabase() or close() 被調(diào)用

異常

SQLiteException 如果數(shù)據(jù)庫不能被打開

public synchronized SQLiteDatabase getWritableDatabase ()

創(chuàng)建或打開一個數(shù)據(jù)庫,用于讀寫。該方法第一次被調(diào)用的時候,數(shù)據(jù)庫被打開,并且onCreate(SQLiteDatabase),onUpgrade(SQLiteDatabase,intint) onOpen(SQLiteDatabase)將被調(diào)用。

一旦成功打開,數(shù)據(jù)庫將被緩存,所以需要寫入數(shù)據(jù)的時候你可以調(diào)用這個方法。(當(dāng)你不再需要這個數(shù)據(jù)庫的時候,確保調(diào)用close())。像不健康的許可或磁盤已滿等錯誤都可能導(dǎo)致該方法是不,但是如果該問題被解決,將來的嘗試可能會成功。

數(shù)據(jù)庫升級可能會話費很長的時間,所以你不該在應(yīng)用程序的主線程中調(diào)用它,包括方法ContentProvider.onCreate()。

返回值

一個有效的讀寫數(shù)據(jù)庫對象直到close()被調(diào)用。

異常

SQLiteException 如果數(shù)據(jù)庫不能被打開用于寫入

public abstract void onCreate (SQLiteDatabase db)

當(dāng)?shù)谝淮蝿?chuàng)建數(shù)據(jù)庫時調(diào)用。表格的創(chuàng)建和初始化表格的個數(shù)在這里完成。

參數(shù)

db 數(shù)據(jù)庫

public void onDowngrade (SQLiteDatabase db, int oldVersion, int newVersion)

當(dāng)數(shù)據(jù)庫需要降低版本時候調(diào)用。這個方法跟onUpgrade()很相似,但是只要當(dāng)然版本比被請求的更新,它就會被調(diào)用。盡管如此,這個方法不是抽象的,所以它并不強制用戶去實現(xiàn)它。如果不被重寫,默認(rèn)的實現(xiàn)將會拒絕降級并且拋出一個SQLiteException

參數(shù)

db 數(shù)據(jù)庫

oldVersionThe 舊版本數(shù)據(jù)庫

newVersionThe 新版本數(shù)據(jù)庫

public void onOpen (SQLiteDatabase db)

當(dāng)數(shù)據(jù)庫打開時調(diào)用。這個實現(xiàn)會在升級數(shù)據(jù)庫之前會檢查isReadOnly()

參數(shù)

db 數(shù)據(jù)庫

public abstract void onUpgrade (SQLiteDatabase db, int oldVersion, int newVersion)

當(dāng)數(shù)據(jù)庫升級時調(diào)用。這個實現(xiàn)需要使用該方法去丟棄表格,增加表格,或者做一些其它事情,它需要升級到新的計劃中的版本。

SQLite ALTER TABLE文檔可以在這找到。如果你添加新的列,你可以使用ALTER TABLE 去把它們插入到活著的表格中。如果你重命名或移動列,你可以使用ALTER TABLE去重命名這些舊的表格,然后創(chuàng)建新的表格,之后把舊表格的數(shù)據(jù)放到新的表格上。

參數(shù)

db 數(shù)據(jù)庫

oldVersionThe 舊版本數(shù)據(jù)庫

newVersionThe 新版本數(shù)據(jù)庫

補充

文章精選

android SQLiteOpenHelper使用示例


Article précédent: Article suivant: