2012-05-07 27 views
1

我想在我的儀器測試用例中創建一個tmp目錄。我試過 this.getInstrumentation().getContext().getDir("tmp", 0),但它無法在data/data/package-name目錄下創建目錄。我想,儀器測試軟件包和普通軟件包有一些區別。Android:在儀器測試用例中創建目錄

有人可以幫助我嗎?

+0

測試包的內部存儲 – Dagang

回答

1

假設您的應用程序項目包名稱爲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); 

希望這會有所幫助。