我已将数据库文件放入 assets 文件夹中,并希望将其复制到 /data/data//database folder 。为此,我编写了以下代码:
public void copy()
{
    try
    {
        String dest_path = "/data/data/"+getPackageName()+"/database/sultandatabase";
        File f = new File(dest_path);
        if( !f.exists() )
        {
            copy_database(getBaseContext().getAssets().open(db_name),new FileOutputStream(dest_path));
        }
    }
    catch(Exception e)
    {
        Toast.makeText(this,"Sorry the file can not be opended", Toast.LENGTH_LONG).show();
    }
}
public void copy_database(InputStream io ,OutputStream ou) throws Exception
{
    byte[] buffer = new byte[1024] ;
    int lenght;
    while( ( lenght = io.read(buffer)) > 0 )
        ou.write(buffer);
    io.close();
    ou.close();
}
当我调用 copy() 时,不会复制数据库文件。可能的原因是什么??我怎样才能解决这个问题 ??而是出现了一个祝酒词。这意味着我的程序得到 Exception ?? 但为什么 ??