筆者完成了 Android 12 內部存儲空間(Internal Storage)的路徑測試程式,也開始實驗 Android 12 外部存儲空間(External Storage)的路徑測試程式。
Android Studio - Android 12 外部存儲空間路徑程式(一百零九): |
操作系統:Windows 7 64-bit 版本
開發環境:Android Studio 4.0.1 版本
最低 SDK 版本:minSdkVersion 24
測試手機:Samsung Galaxy M33 5G
測試手機系統版本:Android 12(Snow Cone / 2021)
原程式:C:\Development\Development_Android\DIY-Android-190-15d Android12ReadWriteFile bugworkshop 20230304 - ReadWriteFileStorage
程式:C:\Development\Development_Android\Android_Project\DIY-Android-190-15d Android12ReadWriteFile bugworkshop 20230304 - ReadWriteFileStorage
MainActivity.java:
public void externallStorage(){
mtxt_hello.setText("External - Read Write Storage"); String PackageName = getPackageName(); Log.d(MainActivity.TAG, "ReadWriteFileInt.internalStorage().getPackageName=" + PackageName );
// File File getExternalFilesDir = new File(getExternalFilesDir(""), "fileName"); File getExternalCacheDir = new File(getExternalCacheDir(), "fileName");
//File[] getExternalMediaDirs = new File(getExternalCacheDirs(), "fileName");
// String String getExternalStorageDirectory = Environment.getExternalStorageDirectory().getPath(); String getExternalStoragePublicDirectory = Environment.getExternalStoragePublicDirectory("file").getPath(); String getExternalStorageState = Environment.getExternalStorageState();
// String File dcimgetExternalStoragePublicDirectory = new File(getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "fileName"); String dcimDirectory = Environment.DIRECTORY_DCIM; String musicDirectory = Environment.DIRECTORY_MUSIC; String podcastsDirectory = Environment.DIRECTORY_PODCASTS; String ringtonesDirectory = Environment.DIRECTORY_RINGTONES; String alarmDirectory = Environment.DIRECTORY_ALARMS; String notificationDirectory = Environment.DIRECTORY_NOTIFICATIONS; String picturesDirectory = Environment.DIRECTORY_PICTURES; String moviesDirectory = Environment.DIRECTORY_MOVIES; String downloadsDirectory = Environment.DIRECTORY_DOWNLOADS; String documentsDirectory = Environment.DIRECTORY_DOCUMENTS;
String content = ""; // File content = content + "getExternalFilesDir=" + getExternalFilesDir + "\n"; content = content + "getExternalCacheDir=" + getExternalCacheDir + "\n"; content = content + "Environment.getExternalStorageDirectory=" + getExternalStorageDirectory + "\n"; content = content + "Environment.getExternalStoragePublicDirectory=" + getExternalStoragePublicDirectory + "\n"; content = content + "Environment.getExternalStorageState=" + getExternalStorageState + "\n";
// String content = content + "Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)==" + dcimgetExternalStoragePublicDirectory + "\n"; content = content + "Environment.DIRECTORY_DCIM=" + dcimDirectory + "\n"; content = content + "Environment.DIRECTORY_MUSIC=" + musicDirectory + "\n"; content = content + "Environment.DIRECTORY_PODCASTS=" + podcastsDirectory + "\n"; content = content + "Environment.DIRECTORY_RINGTONES=" + ringtonesDirectory + "\n"; content = content + "Environment.DIRECTORY_ALARMS=" + alarmDirectory + "\n"; content = content + "Environment.DIRECTORY_NOTIFICATIONS=" + notificationDirectory + "\n"; content = content + "Environment.DIRECTORY_PICTURES=" + picturesDirectory + "\n"; content = content + "Environment.DIRECTORY_MOVIES=" + moviesDirectory + "\n"; content = content + "Environment.DIRECTORY_DOWNLOADS=" + downloadsDirectory + "\n"; content = content + "Environment.DIRECTORY_DOCUMENTS=" + documentsDirectory + "\n";
mtxt_filecontent.setText(content); } |
沒有留言:
張貼留言