问题
The following code snippet is trying to store a Gesture
object.
private Gesture mGesture;
private GestureLibrary store;
store.addGesture("test", mGesture);
store.save();
I'm wondering where is mGesture
stored?
Just followed by the above code, the author gives the following code:
final String path = new File(Environment.getExternalStorageDirectory(),
"gestures").getAbsolutePath();
Toast.makeText(this, getString(R.string.save_success, path), Toast.LENGTH_LONG).show();
So I guess the mGesture
is stored in somewhere indicated by path
.
But I don't know what's path. I've tried debugging. It gives me something like: "storage/emulated/0/gestures/". But I can't find this directory on my device.
By the way, my device is nexus 4
回答1:
Nexus devices don't have an SD slot. They pretend that somewhere on the internal drive is an SD card. But the exact path returned by the function does exist on your device, otherwise you couldn't make a file to it.
By the way, do not depend on that returned value being the same across devices. It isn't.
回答2:
Yea agree with gabe and also this is just a suggestion but you could use if and else alongside mkdirs to check if the directory or folder exists and if it doesnt already exist it will create a new folder in the specified location.
回答3:
As Nexus 4 does not have an external SD, (same thing for Nexus 5, on which I am working now), its OS emulates an SD temporarily. Thus, calling Environment.getExternalStorageDirectory()
returns the following path: tempDirPath:/storage/emulated/0/
, but it can be later accessed by you at /storage/emulated/legacy
.
Try accessing it via adb shell
, this legacy
folder will store the content of the emulated external SD.
来源:https://stackoverflow.com/questions/16027995/whats-the-directory-of-external-storage-on-nexus-lg