2, cd /data/data/com.android.providers.media/databases
3, ls(查看 com.android.providers.media下面的数据库)
4, sqlite3 internal.db
5, .help— 看看如何操作
6, .table列出internal数据中的表
7, select * from albums; ——————————————————————————————— DatabaseHelper mOpenHelper; private static final String DATABASE_NAME = “dbForTest.db”; private static final int DATABASE_VERSION = 1; private static final String TABLE_NAME = “diary”; private static final String TITLE = “title”; private static final String BODY = “body”; private static class DatabaseHelper extends SQLiteOpenHelper { DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { String sql = “CREATE TABLE ” + TABLE_NAME + ” (” + TITLE + ” text not null, ” + BODY + ” text not null ” + “);”; Log.i(“haiyang:createDB=”, sql); db.execSQL(sql); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } } /* * 重新建立数据表 */ private void CreateTable() { SQLiteDatabase db = mOpenHelper.getWritableDatabase(); String sql = “CREATE TABLE ” + TABLE_NAME + ” (” + TITLE + ” text not null, ” + BODY + ” text not null ” + “);”; Log.i(“haiyang:createDB=”, sql); try { db.execSQL(“DROP TABLE IF EXISTS diary”); db.execSQL(sql); setTitle(” 数据表成功重建”); } catch (SQLException e) { setTitle(“数据表重建错误”); } } /* * 删除数据表 */ private void dropTable() { SQLiteDatabase db = mOpenHelper.getWritableDatabase(); String sql = “drop table ” + TABLE_NAME; try { db.execSQL(sql); setTitle(“数据表成功删除:” + sql); } catch (SQLException e) { setTitle(“数据表删除错误”); } } /* * 插入两条数据 */ private void insertItem() { SQLiteDatabase db = mOpenHelper.getWritableDatabase(); String sql1 = “insert into ” + TABLE_NAME + ” (” + TITLE + “, ” + BODY + “) values(‘haiyang’, ‘android的发展真是迅速啊’);”; String sql2 = “insert into ” + TABLE_NAME + ” (” + TITLE + “, ” + BODY + “) values(‘icesky’, ‘android的发展真是迅速啊’);”; try { Log.i(“haiyang:sql1=”, sql1); Log.i(“haiyang:sql2=”, sql2); db.execSQL(sql1); db.execSQL(sql2); setTitle(” 插入两条数据成功”); } catch (SQLException e) { setTitle(“插入两条数据失败”); } } /* * 删除其中的一条数据 */ private void deleteItem() { try { SQLiteDatabase db = mOpenHelper.getWritableDatabase(); db.delete(TABLE_NAME, ” title = ‘haiyang'”, null); setTitle(“删除title为haiyang的一条记录”); } catch (SQLException e) { } } /* * 在屏幕的title区域显示当前数据表当中的数据的条数。 */ private void showItems() { SQLiteDatabase db = mOpenHelper.getReadableDatabase(); String col[] = { TITLE, BODY }; Cursor cur = db.query(TABLE_NAME, col, null, null, null, null, null); Integer num = cur.getCount(); setTitle(Integer.toString(num) + ” 条记录”); } ——————————————————————————————— 四,Network
这是借助Internet来存储我们要的数据,这是CS结构的存储方式,也是点一下名了。
如何使用 Content Provider
下边是用户经常接触到的几个典型Content Provider应用:
* Content Provider Name : Intended Data * Browser : Browser bookmarks, Browser history, etc. * CallLog : Missed calls, Call datails, etc. * Contacts : Contact details * MediaStore : Media files such as audio, Video and Images * Settings : Device Settings and Preferences