Bloggers in the learning process just found a question about the Android to SDcard Read and write,
There is no read and write permission to prompt for this configuration.
Configure the list in the Androidmanifest.xml file for example the following
<manifest xmlns:android= "Http://schemas.android.com/apk/res/android"
Package= "Com.example.custom"
Android:versioncode= "1"
Android:versionname= "1.0" >
<uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name= "Android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-sdk
Android:minsdkversion= "8"
Android:targetsdkversion= "/>"
<application
Android:allowbackup= "true"
android:icon= "@drawable/ic_launcher"
Android:label= "@string/app_name"
Android:theme= "@style/apptheme" >
<provider
Android:name= "Custom_content_provider. Regioncontentprovider "
android:authorities= "Mobile.android.wang.hao.regioncontent"/>
<activity android:name= "Custom_content_provider. Main ">
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
The code for writing files to sdcard such as the following
Open Database
Private Sqlitedatabase OpenDatabase () {
LOG.D ("Error", "OpenDatabase");
InputStream is = null;
FileOutputStream fos = null;
try{
if (Environment.getexternalstoragestate (). Equals (environment.media_mounted)) {
Get file Folder
String dbfilename = environment.getexternalstoragedirectory () + "/region.db";
LOG.D ("error", Dbfilename);
if (! ( New File (Dbfilename). Exists ()) {File does not exist copy
is = GetContext (). Getresources (). Getassets (). Open ("region.db");
FOS = new FileOutputStream (dbfilename);
byte[] buffer = new byte[8192];
int count = 0;
while ((Count=is.read (buffer)) >0) {
Fos.write (Buffer,0,count);
}
}
}else{
LOG.D ("Error", "no Read and Write permission" +environment.getexternalstoragedirectory () + "/region.db");
}
}catch (Exception ex) {
LOG.D ("Error", Ex.getmessage ());
}finally{
Close Flow slightly ...
}
return null;
Then execute the prompt without permission to access the SDcard path, but our configuration is also configured. The internet has said that the SDK version number of the problem,
Say 2.2 After the version number can not be created with FileOutputStream file, a half day. Still the same, I finally tried it with my cell phone,
The discovery file was created successfully, suddenly. I thought for a moment, is there a sdcard?
D---------, the problem is here, is not the virtual machine loaded sdcard. Immediately after that, I restarted a piece. OK, fix it.
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvd2gxmdy2mdm0/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">
Android SDcard One of the read and write permissions issues