三、对上面管理类的使用方法,示例代码如下:
//建立Sqlite数据库所需 DBCipherHelper.DB_NAME="testDB"; DBCipherHelper.DB_PWD="shy"; DBCipherHelper.DB_VERSION=1; //创建表所需 String tableName="proofPhotoInfo"; String createTableSQL="CREATE TABLE "+tableName+"(ID integer primary key autoincrement,layerName text not null,picName text not null,azimuth text,pitch text,roll text,longitude text not null,latitude text not null);";//在SQLite数据库中创建表SQL语句(该表用于存储该类中信息) //1、建库和建表 try { DBCipherManager.getInstance(context).execSQL(createTableSQL);//建库和建表 } catch (Exception e) { e.printStackTrace(); } //2、插入数据 ContentValues photoInfo=new ContentValues(); photoInfo.put("layerName",CameraClass.layerDirName); photoInfo.put("picName",basicDOClass.getFileName(CameraClass.currenImgFilePath)); photoInfo.put("azimuth",SensorEx.azimuth+""); photoInfo.put("pitch",SensorEx.pitch+""); photoInfo.put("roll",SensorEx.roll+""); photoInfo.put("longitude",SensorEx.longitude+""); photoInfo.put("latitude",SensorEx.latitude+""); DBCipherManager.getInstance(context).insertData(tableName,photoInfo);//插入数据 //3、查询数据 StringBuffer querySQLWhere=new StringBuffer(); String layerName=basicDOClass.getDirName(basicDOClass.getFilePath(photoPath)); String picName=basicDOClass.getFileName(photoPath); querySQLWhere.append("layerName").append("=").append("'").append(layerName).append("'").append(" and ").append("picName").append("=").append("'").append(picName).append("'"); queryPhotoInfoResult=DBCipherManager.getInstance(context).queryDatas(tableName,querySQLWhere,new String[]{"ID","layerName","picName","azimuth","pitch","roll","longitude","latitude"});//查询数据