I am developing an Android application using Eclipse/Ubuntu. As usual, I am doing the first shot on an AVD emulator. I would like to put in place a unique folder structure that I can use on both the current emulator and on the final physical device (the SD memory card). What would be the Android environment variable to pick up the root directory by program (Java of course) for both type of virtual and physical devices, so that I can have my starting reference? Thanks PS: I have the DDMS File Explorer open, in case the answer refers to the structure there
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can see that http://developer.android.com/reference/android/os/Environment.html to get the "same" directory with getExternalStorageDirectory()
method
回答2:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
You need user permission if you want to write in storage
File root = Environment.getExternalStorageDirectory();
This will create instance of your root directory