測(cè)試手機(jī)ZTE B2015
1.獲取內(nèi)置sd卡存儲(chǔ)空間的路徑
if(Environment.getExternalStorageState.equals(Environment.MEDIA_MOUNTED)
{
??? Environment.getExternalStorageDirectory.getAbsolutePath();
??? 返回 /storage/emulated/0
}
不管外置sd卡是否插入,以上代碼都是獲取內(nèi)置存儲(chǔ)(內(nèi)置sd卡)的路徑
2.獲取內(nèi)部存儲(chǔ)路徑
String innerPath = Context.getFilesDir().getAbsolutePath()
返回/data/data/com.example.appname/files
可以在該目錄下建立文件。
File file = new File(innerPath + "/" + "fileName");
file.createNewFile();
也可以通過(guò)Context.openFileOutput("fileName",Context.MODE_PRIVATE)在innerPath目錄中來(lái)建立文件,并且得到一個(gè)FileOutputStream對(duì)象;