如何使用ActionAndroid _Android Studio更改保存DataBase的路径?

时间:2015-08-01 10:26:17

标签: android android-sqlite

我在我的项目中使用ActionAndroid

如何更改保存dataBase的路径。

2 个答案:

答案 0 :(得分:0)

File backupDB = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "Database.db");
File currentDB = context.getDatabasePath(DATABASE_NAME);
if (currentDB.exists()) {
FileChannel src = new FileInputStream(currentDB).getChannel();
FileChannel dst = new FileOutputStream(backupDB).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
}

您还需要获得许可

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

答案 1 :(得分:0)

试试这个;

<manifest ...>
        <application android:name="com.activeandroid.app.Application" ...>

            ...

            <meta-data android:name="AA_DB_NAME" android:value="/mnt/sdcard/Pickrand.db" />
            <meta-data android:name="AA_DB_VERSION" android:value="5" />

        </application>
    </manifest>