mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Use API for sdcard path.
This commit is contained in:
@@ -19,27 +19,32 @@
|
|||||||
*/
|
*/
|
||||||
package com.keepassdroid.tests.database;
|
package com.keepassdroid.tests.database;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
|
import android.os.Environment;
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
import com.keepassdroid.database.load.ImporterV3;
|
import com.keepassdroid.database.load.ImporterV3;
|
||||||
import com.keepassdroid.tests.TestUtil;
|
import com.keepassdroid.tests.TestUtil;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class Kdb3 extends AndroidTestCase {
|
public class Kdb3 extends AndroidTestCase {
|
||||||
|
|
||||||
private void testKeyfile(String dbAsset, String keyAsset, String password) throws Exception {
|
private void testKeyfile(String dbAsset, String keyAsset, String password) throws Exception {
|
||||||
Context ctx = getContext();
|
Context ctx = getContext();
|
||||||
|
|
||||||
|
File sdcard = Environment.getExternalStorageDirectory();
|
||||||
|
String keyPath = sdcard.getAbsolutePath() + "/key";
|
||||||
|
|
||||||
TestUtil.extractKey(ctx, keyAsset, "/sdcard/key");
|
TestUtil.extractKey(ctx, keyAsset, keyPath);
|
||||||
|
|
||||||
AssetManager am = ctx.getAssets();
|
AssetManager am = ctx.getAssets();
|
||||||
InputStream is = am.open(dbAsset, AssetManager.ACCESS_STREAMING);
|
InputStream is = am.open(dbAsset, AssetManager.ACCESS_STREAMING);
|
||||||
|
|
||||||
ImporterV3 importer = new ImporterV3();
|
ImporterV3 importer = new ImporterV3();
|
||||||
importer.openDatabase(is, password, "/sdcard/key");
|
importer.openDatabase(is, password, keyPath);
|
||||||
|
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user