更新放置在资产文件夹中的预填充数据库

时间:2011-06-23 08:21:25

标签: android database assets

我的应用程序已将预先填充的数据库存储/驻留在资源文件夹下的资产文件夹中。 我可以读它。但是我怎么能得到一个可写的数据库句柄becoz我想更新那个预先填充的数据库。

public Database_Opener(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
            this.context = context;
        }
        public void create_Database() throws IOException{
            boolean DBExists = checkDatabaseExistance();

            if(DBExists){

//              Do Nothing Becoz Database is Already Exists
                Log.i("Database", " Is Already Exists");
            }else{
//              Create and Copy Database 
                Log.i("Database", " Doesn't Exist and need to be Created");
//                              this is just a readable database handle
                this.getReadableDatabase();
                try {
                    copyDataBase();
                } catch (Exception e) {

                    throw new Error("Error Copying Database");
                }
            }
            Log.i("Existing Database " ," IS successfully Opened");
        }

1 个答案:

答案 0 :(得分:0)

您无法更新资产。欢迎您更新在内部存储空间(例如getDatabasePath())或外部存储空间中创建的资产的副本。