Android 读取assets的数据库文件

<span style="font-size:18px;">public class DBManger {


	public static final String DB_NAME = "festival.db";//数据库
	public static final String PACKAGE_NAME = "com.example.viewpager_homework2";
	// 在手机存放数据库的位置
	public final String DB_PATH = "/data"
			+ Environment.getDataDirectory().getAbsolutePath() + "/"
			+ PACKAGE_NAME + "/" + DB_NAME; // 在手机里存放数据库的位置


	private SQLiteDatabase database;
	private Context context;


	public DBManger(Context context) {
		super();
		this.context = context;
	}


	public void openDatabase() {


		this.database = this.openDatabase(DB_PATH);


	}
	
	public Cursor infor(String string){
		
		SQLiteDatabase db = this.openDatabase(DB_PATH);
		
		return db.rawQuery("select * from smstb where fes_id = "+string, null);
		
	}
	


	private SQLiteDatabase openDatabase(String dbfile) {
		try {
			if (!(new File(dbfile).exists())) {// 判断数据库文件是否存在,若不存在则执行导入,不然直接打开数据库


				Log.i("info", "qq");
				InputStream is = this.context.getResources().getAssets()
						.open("festival.db"); // 欲导入的数据库
				// InputStream is = this.context.getResources().openRawResource(
				// R.raw.);
				Log.i("info", "qq1");
				FileOutputStream fos = new FileOutputStream(dbfile);
				byte[] buffer = new byte[1024];
				int count = 0;
				Log.i("info", "qq2");
				while ((count = is.read(buffer)) != -1) {
					fos.write(buffer, 0, count);
					Log.i("info", buffer.length + "");
					fos.flush();
				}
				fos.close();
				is.close();
			}


			SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile,
					null);


			return db;
		} catch (FileNotFoundException e) {
			Log.e("Database", "File not found");
			e.printStackTrace();
		} catch (IOException e) {
			Log.e("Database", "IO exception");
			e.printStackTrace();
		}
		return null;
	}


	public void closeDatabase() {
		this.database.close();
	}


}</span>


检查数据库文件有没有写入,能够点击DDMS按钮, 在data文件夹下点击data文件夹找到对应的报名。java