我想在我的检测测试用例中创建一个tmp目录。我试过了
this.getInstrumentation().getContext().getDir("tmp", 0)
,但无法在data / data / package-name目录下创建目录。我猜,仪器测试包和普通包之间存在一些差异。
有人可以帮我吗?
答案 0 :(得分:2)
假设您的应用程序项目的包名为com.example
,并且您的测试项目的包名为com.example.test
。
// This will create app_tmp1 directory under data/data/com.example.test/
this.getInstrumentation().getContext().getDir("tmp1", 0);
// This will create app_tmp2 directory under data/data/com.example/
this.getInstrumentation().getTargetContext().getDir("tmp2", 0);
希望这有帮助。