How to create folders and modify permissions in Android
Each application package has a private data storage directory. Only the application that belongs to this package has the permission to write data to this directory. Its absolute path: /data/<package name>/directory. In addition to Private Data Directories, applications can also read and write sdcards. Third-party applications cannot be written to other system directories in the file system.
// Create a folder
File destdir = new file ("/data/<package name>/<folder> ");
If (! Destdir. exists ()){
Destdir. mkdirs ();
}
// Modify permissions
Fileoutputstream Fos;
Fos = openfileoutput ("FILENAME", mode_world_readable );
/* Mode:
Public static final int mode_private = 0x0000; // The owner can access and overwrite and save data.
Public static final int mode_world_readable = 0x0001; // The owner can access and append the data to save.
Public static final int mode_world_writeable = 0x0002;
Public static final int mode_append = 0x8000;
*/
// Sdcard. You must first determine whether the sdcard is inserted.
String status = environment. getexternalstoragestate ();
If (status. Equals (environment. media_mounted )){
Return true;
}
Else {
Return false;
}
// Obtain the absolute path of the sdcard
Enviroment. getexternalstoragedirectory ();
// Obtain the absolute path of the phone memory (/data/<pacage Name>/files)
Activity. getfilesdir ();
// Obtain the cache directory (/data/<pacage Name>/cache );
Activity. getcachedir ();