Info

readme txt

JP'hJPlR

ft ^Ä SQLiteOpenJIelper ?

Ä + flÄtiM^tö;* fc getWritableDatabaseO getRcadableDatabaseO^ÜftBift, in^ g # JS|S£ Android

• onCreate (SQLiteDatabase): ftMW^ ft'k £ MJ'lliS t //ii. --«WW J/fig

• onUpgrade (SQLiteDatabase, int, int): ^i&frili'^S/ligWlMK, Android k^jWiffl im^Jy/i. if it

• onOpen (SQLiteDatabase):

SHfJ/l: ActivityMain Xf^STii&^ft SB^o DatabaseHelper SQLiteOpenHelper . ft private static class DatabaseHelper extends SQLiteOpenHelper I DatabaseHelper(Context context) {

super(context, DATARASE NAME, null, DATABASE VERSION); \

(¿Override public void onCreate(SQLiteDatabase db) ( // SQLiS'S]

String sql = "CREATE TABLE " + TABLE NAME + " (" + TITLE + " text not null, " ► BODY + " text not null " + ");"• Log.i("haiyang:createDB=", sql); //tMji&fc SQLii^il db.execSQL(sql);

@Overr Lde public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) (

• DatabaseHelper f SQLiteOpenHelper )|' H.M'4 T onCreate in onUpgrade JjiM*

• 4: onCreate() fj)i -P.ii fr&IMJftliS & SQL UifTJ, ^Jn^ll] db.execSQL(sql)JMr SQL i & i.Jo && SQL

• i I limifJib^fflffifl-«»«J?-. WWMJ4 onUpgradc()®^MiiSW^ifir:M»f1=-o 4. ^ffl^

aifJ^.BMAWilfc-id^Wficffl. toiK»«$iMS-Afi]

«rlfa^ttflijg, WJr^UTriKlWif^lfft onClick ti il. n-hkmXly J K^ffiiT-miWinsertltem JWV^it ii'Sin private void insertItem() ] SQLiteDatabase db - mOpenHelper.getWritableDatabase<); SQL il^

String sqil = "insert into " »■ TABLE NAME + " (" + TITLE + ", M + 30DY 4- ") values (' haiyang ' , • Android ');" ;

String sql2 "insert into " + TA3LE NAME + " (" + TITLE + ", " + BODY + ") values Cicesky', 'Android '); ";

Log. i ("haiyang: sqll ", sqll); Log.i("haiyang:sql2=" , sql2); db.execSQL(sqll) ; db.execSQL(sql2) ; s e t Ti 11 e ( " ji A W & ft j§ fii V)") ; } catch (SQLException e) (

setTitler«AWfcft«ifefgr) ;

% immni

• SQLiteDatabase db mOpenHelper.getWritableDatabase()i* & ig fij ft ^iif'^tt SQLite »«■/£, B& mOpen Helper mMmifitt ill I

• sqll fll sql2 ^«CJ^lSMfeitWttA SQL SQL BKfl

• db.execSQL (sqll ) ifH'M SQL. ifrfJJUtirtkiTo

Android ^^T^^J^^ ^ D i Android X¥f 5 Verbose. Debug. Info. Warning. Error.

[3 Consol*

0 u«c»t

Search TV SVK SSj&It CI File Explor

ar Properti«s Debug

0 0

Post a comment