Android SQLITE ¼òµ¥Æð²½
1£º¶¨Òå±íµÄ½á¹¹ºÍÃû×Ö£¬ÎÒʹÓÃÒÔÏ·½·¨£º
public interface Constatnts extends BaseColumns {
public static final String TABLE_NAME = "test";
public static final String TIME = "time";
public static final String TITLE = "title";
}
ÔÚÕâÀÎҼ̳ÐBaseColumnsµÄÄ¿µÄ£¬ÊÇÖ±½Ó¶¨Òå"_ID"×Ö¶Î
2£º¶¨ÒåSQLiteOpenHelper µÄ×ÓÀ࣬À´¶ÔÓ¦Ò»¸öÊý¾Ý¿â£¬ÖØÔرØÐëµÄonCreate ºÍ onUpgrade¡£ÀïÃæÍ¨¹ýexecSQLµ÷ÓÃÊʵ±µÄSQL Óï¾ä¡£
@Override
// Õâ¸öº¯Êý»áÔÚµÚÒ»´ÎÖ´ÐÐÊý¾Ý¿â²Ù×÷µÄʱºò±»µ÷Óõ½¡£
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + _ID
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + TIME
+ " INTEGER," + TITLE + " TEXT NOT NULL);"); //×¢Ò⣬×îºÃÉùÃ÷×Ö¶ÎÀàÐÍ£¬ÒÔÃâ²»±ØÒªµÄÂé·³¡£
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
db.execSQL("DROP TABLE IF EXITS "+ TABLE_NAME);
onCreate(db);
}
3£ºÊ¹ÓøÃÊý¾Ý¿â¡£
mydatabase = new Databasehelp(this);
²åÈëÊý¾Ý£º
SQLiteDatabase db = mydatabase.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(TIME, System.currentTimeMillis());
values.put(TITLE, string);
db.insertOrThrow(TABLE_NAME, null, values);
²éѯÊý¾Ý£º
SQLiteDatabase db = mydatabase.getReadableDatabase();
Cursor cursor = db.query(TABLE_NAME, { _ID, TIME, TITLE, }, null, null, null,
 
Ïà¹ØÎĵµ£º
AutoIt3¿ª·¢µÄ²Ù×÷SQliteÊý¾Ý¿âµÄÔ´ÂëÏÂÔØ
²¿·ÖÔ´Âë
_SQLite_Startup () ;¼ÓÔØ SQLite.dll
If Not FileExists($SQLite_Data_Path) Then
SQLCreate()
EndIf
$GUI_Form = GUICreate($Title, 300, 435, -1, -1)
GUISetBkColor(0xECE9D8) ; will change background color
$GUI_ListBox = GUIC ......
ÔÚ .NET ÀïÃæÊ¹Óà SQLite£¬ ÎÒÕâÀïʹÓõÄwrapperÊÇ System.Data.SQLite£¬ËüÖ»ÐèÒªÒ»¸ödll,½Ó¿Ú·ûºÏADO.Net 2.0µÄ¶¨Òå,ÐÔÄÜÒ²²»´í,NHibernateÓõÄÒ²ÊÇËü£¬Ä¿Ç°Ö§³ÖADO.NET 3.5ÁË£¬Ö§³Ö¼¯³ÉÔÚ VS2005 ºÍ VS2008ÀïÃæ£¬¶øÇÒÖ§³Öwince£¬ÊǸöÁÁµã
ÒòΪ·ûºÏADO.NETµÄ¹æ·¶£¬ËùÒÔʹÓ÷½Ê½£¬»ù±¾ºÍ SqlClient, OleDbµÈÔÉúµÄÒ»ÖÂ
us ......
Ò»¡¢SQLite¼ò½é
SQLite ÊÇÓÃCÓïÑÔ±àдµÄ¿ªÔ´Êý¾Ý¿â£¬Ö÷ÒªÓÃÓÚǶÈëʽ£¬ÄãÒ²¿ÉÒÔ°ÑËü¼¯³ÉÔÚ×Ô¼ºµÄ×ÀÃæ³ÌÐòÖУ¬Ò²ÓÐÈ˽«ÆäÌæ´úAccess£¬ÓÃ×÷ºǫ́Êý¾Ý¿â¡£
SQLite Ö§³Ö¶àÊýSQL92±ê×¼£¬ÀýÈ磺Ë÷Òý¡¢ÏÞÖÆ¡¢´¥·¢ºÍ²é¿´Ö§³Ö¡£
Ö§³Ö NULL¡¢INTEGER¡¢REAL¡¢TEXT ºÍ BLOB Êý¾ÝÀàÐÍ£¬Ö§³ÖÊÂÎñ¡£
¶þ¡¢ÏÂÔØSQLite
SQLite¿ÉÒÔµ½¹Ù·½Õ ......
SQLiteÊý¾Ý¿âÁ¬½Ó·½Ê½
SQLite.NET
Type: .NET Framework Class Library
Usage: System.Data.SQLite.SQLiteConnection
Basic
Data Source=filename;Version=3;
Version 2 is not supported by this class library.
Using UTF16
Data Source=filename;Version=3;UseUTF16 ......
sqliteÊÇ
Ò»¸ö·Ç³£Ð¡ÇÉµÄ¿çÆ½Ì¨Ç¶ÈëʽÊý¾Ý¿â£¬Ëü±¾Éí²»Ìṩ¼ÓÃܹ¦ÄÜ£¬²»¹ýÉè¼ÆÕßÃ÷ÏÔÒ²¿¼ÂÇÁ˼ÓÃܵķ½°¸£¬ÎÒÃÇÔÚÔ´ÂëÖпÉÒÔÕÒµ½Á½¸öÔ¤ÁôµÄ¼ÓÃܽÓ
¿Ú£ºsqlite3_keyºÍsqlite3_rekey£¬¿ÉÒÔͨ¹ýʵÏÖÕâÁ½¸ö½Ó¿ÚÀ´´ïµ½¼ÓÃܵÄÄ¿µÄ¡£
ÈçºÎ¼ÓÃÜ£¬ÒѾÓкܶàÎÄÕÂÃèÊö£¬¿ÉÒԲο¼:¡¶
......