Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2110924
  • 博文数量: 413
  • 博客积分: 10926
  • 博客等级: 上将
  • 技术积分: 3862
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-09 18:14
文章分类

全部博文(413)

文章存档

2015年(5)

2014年(1)

2013年(5)

2012年(6)

2011年(138)

2010年(85)

2009年(42)

2008年(46)

2007年(26)

2006年(59)

分类: 嵌入式

2010-10-14 15:48:51

  1. Package
    • http://developer.android.com/reference/android/database/package-summary.html
    • http://developer.android.com/reference/android/database/sqlite/package-summary.html
  2. Docs
    • SQLite SQL language

    • Android-SQLite3 超基础入门
      http://tuesdayhoho.javaeye.com/blog/415471
    • Android 开发中使用 SQLite 数据库
      http://www.ibm.com/developerworks/cn/opensource/os-cn-sqlite/index.html
    • Android SQLite常用数据类型

    • Android数据库编程SQLite详解

    • Android (SQLite 数据库与ContentProvider)

    • 在android命令行下使用sqlite3

    • xxx
  3. Class
    1. SQLiteOpenHelper
      A helper class to manage database creation and version management.You create a subclass to takes care of opening the database if it exists, creating it if it does not, and upgrading it as necessary.

      class MyDbHelper implements SQLiteOpenHelper
      {
          ......
      }
      SQLiteOpenHelper dbHelper = new MyDbHelper(context, xxx);
      SQLiteDatabase db = dbHelper.dbHelper.()

    2. SQLiteDatabase
      Exposes methods to manage a SQLite database:create, delete, execute SQL commands, and perform other common database management tasks.

      • Transaction
        Sample:
        db.beginTransaction();try {...db.execSQL(...); db.setTransactionSuccessful();} finally {db.endTransaction();}
      • delete row(s)
      • insert row(s) (depend on ContentValues. ContentValues object represents a row in table, call ContentValues.put to set value of each column. more sample: http://developer.android.com/guide/topics/providers/content-providers.html#modifying)
      • replace
      • update
      • query (query or rawQuery)
      • execSQL
      • getPath
      • setLockingEnabled
        Control whether or not the SQLiteDatabase is made thread-safe
      • xxx

      Datebase class to process datebase, table. You can get an instance of SQLiteDatabase through 2 ways:
      a) SQLiteDatabase db = context.openOrCreateDatabase(, );
      b) Implement the interface SQLiteOpenHelper, and then create its instance,
          class MyDbHelper implements SQLiteOpenHelper
          {
              public void onCreate (SQLiteDatabase db)
              {
                  final String str = "CREATE TABLE IF NOT EXIST tab_name(col_id INTEGER PRIMARY KEY, col_name, TEXT NOT NULL)";
                  db.execSQL(str);
              }
              ......
          }
          SQLiteOpenHelper dbHelper = new MyDbHelper(context, xxx);
          SQLiteDatabase db = SQLiteDatabase.()
    3. xxx
  4. Tools
    • sqlite3
      • launch
        $adb shell
        $sqlite3
        sqlite>
      • Use sqlite command
        sqlite>.help
      • Exec SQL
        sqlite>SELECT * FROM WHERE xxx
      • xxx
    • xxx
  5. tips:
    • Get path of database:
      context.getDatabasePath("dummy").getParent(); //'dummy' is the name of a inexisting db

  6. xxx
阅读(1568) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~