My question should be kinda simple but I search a lot from the internet, cannot find the answer.
I could get the path of secondary removable storage(sdcard) with below code
String ExternalSdcardPath = System.getenv("SECONDARY_STORAGE") + "/Sample/";
and I could get path like this , /storage/external_SD/Sample/
and I tried to create file with NDK API ( fopen(ExternalSdcardPath, "a+"); )
but I couldn't create and read file with fopen..
can you please tell me how to create and read file with fopen api in removable path(secondary_storage) ?
I could get the path of secondary removable storage(sdcard) with below code
There is no requirement for that environment variable to exist, let alone point to something meaningful.
I couldn't create and read file with fopen
You do not have direct filesystem access to arbitrary locations on removable storage on Android 4.4+.
can you please tell me how to create and read file with fopen api in removable path(secondary_storage) ?
Your only places for direct filesystem access to removable storage is in the locations returned by getExternalFilesDirs()
, getExternalCacheDirs()
, and getExternalMediaDirs()
. Those are all methods on Context
(eg, an activity or service). If they return 2+ values, the second and subsequent ones are on removable storage. Your Java code can supply those paths to your NDK code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.