MyOpenHelper helper = new MyOpenHelper(this);//创建数据库 需要调用 getReadableDatabase 或 getWritableDatabasehelper.getReadableDatabase();//返回的数据类型为SQLiteDatabase可以将其传给OnCreate(SQLiteDatabase db)
public void onCreate(SQLiteDatabase db) {//注:(_id是google推荐的)db.execSQL("create table info(_id integer primary key autoincrement,name varchar(20))");}
ContentValues values = new ContentValues ();values.put("name", "张飞");values.put("number","120");db.insert(table,null, values);db.close();
//首先对cursor 进行判断if (cursor!=null && cursor.getCount()>0) {//循环取所有数据while(cursor.moveToNext()){}}
/*** whereClause 删除条件* whereArgs 删除条件的参数*/int delete = db.delete("info", "name=?", new String[]{name});



Open the database according to the flags  
  
  OPEN_READWRITE
 OPEN_READONLY CREATE_IF_NECESSARY and/or NO_LOCALIZED_COLLATORS. | |
Open the database according to the flags  
  
  OPEN_READWRITE
 OPEN_READONLY CREATE_IF_NECESSARY and/or NO_LOCALIZED_COLLATORS. | |
Equivalent to openDatabase(path, factory, CREATE_IF_NECESSARY, errorHandler). 
  
   | |
Equivalent to openDatabase(path, factory, CREATE_IF_NECESSARY). 
  
   | |
Equivalent to openDatabase(file.getPath(), factory, CREATE_IF_NECESSARY).  | 
原文:http://www.cnblogs.com/candledragle/p/4249256.html