How using SQLiteOpenHelper with database on sd-card?

后端 未结 6 799
渐次进展
渐次进展 2021-02-08 00:50

According to various answers here and in the web extending Application and it\'s inherited method getDatabasePath() would allow to set the database storage path from the standar

6条回答
  •  隐瞒了意图╮
    2021-02-08 01:05

    This code fixed my similar problem, my application class:

    @Override
    public File getDatabasePath(String name) {
        File result = new File(getExternalFilesDir(null), name);
        return result;
    }
    
    @Override
    public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory) {
        return SQLiteDatabase.openOrCreateDatabase(getDatabasePath(name), factory);
    }
    

    Hope it will help you.

提交回复
热议问题