In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article "Android can not create a directory in the SD card how to solve" most people do not understand, so the editor summed up the following content, detailed, clear steps, with a certain reference value, I hope you can get something after reading this article, let's take a look at this "Android can not create a directory in the SD card how to solve" article bar.
Abstract
A problem encountered in today's development is that the project cannot create a directory on the SD card of Android6.0 devices. Mobile devices below Android6.0 have tested 5.0,4.3 devices, all of which are normal, but not normal in Android6.0.
After troubleshooting, the following code could not create a directory on a 6.0 device
File dir = new File (DbConfig.BASE_PATH); if (! dir.exists ()) {dir.mkdirs ();}
Derivative knowledge
Google released Android M and named it "Marshmallow" at the Google Iamp O developer Conference on May 29th, 2015. For developers, Android 6.0 (API 23) brings some changes to developers.
Rights management is the biggest change in Android M
Change description:
Permission management is more elaborate and has changed from static authorization at installation time to dynamic authorization at run time.
People have been complaining about the permissions of Android for a long time, and Android should be able to greatly improve this problem.
The main changes are:
In the system settings, each permission of the APP can be individually controlled and grouped according to the content.
Normal permissions are granted at installation time, other permissions are authorized at run time, and the purpose of using this permission should be resolved.
For developers, permissions-related issues need to be handled carefully. When using a feature, you need to always determine whether you have permission to change, and request user authorization in an appropriate way.
Now describe the solution to the process.
1 initiate the permission to read and write the storage space of the device
ActivityCompat.requestPermissions (AppStartActivity.this,new String [] {android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1)
2 write permission request return function
@ Overridepublic void onRequestPermissionsResult (int requestCode, String [] permissions, int [] grantResults) {boolean writeAccepted = false; switch (requestCode) {case 1: writeAccepted = grantResults [0] = = PackageManager.PERMISSION_GRANTED; break;}}
3 execute the create directory code
If (writeAccepted) {String state = Environment.getExternalStorageState (); if (Environment.MEDIA_MOUNTED.equals (state)) {File dir = new File (DbConfig.BASE_PATH); if (! dir.exists ()) {dir.mkdirs () } the above is about the content of this article "how to solve the problem that Android cannot create a directory on SD card". I believe everyone has a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about related knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.