Get Android device/emulator root directory

China☆狼群 提交于 2019-12-11 04:45:27

问题


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



来源:https://stackoverflow.com/questions/12027830/get-android-device-emulator-root-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!