How do I find everything that's readable on Android devices?

I am sorry for my poor English grammar.

I want to know if android devices have read only and read / write on the same device?

If so, how do I get the readOnly Storage directory.

String path = Environment.getExternalStorageDirectory().toString();

      

With this code, you can get the path to the main storage device.

What I really want to do is get all the internal and external storage directories and check if they are read-only or write-only.

Is it possible to find all directories and check if the entry is available?

+3


source to share


1 answer


If the SD card is readable, you can get all files and folders in a simple way:

String sdPath = Environment.getExternalStorageDirectory().getAbsolutePath();

      

Then it's easy to get the list of files with:

File sdFile = new File(sdPath);
File fileList[] = sdFile.listFiles();

      



After getting the list, you can check if the file is readable, writeable, or both. Also, if it is a file or a directory, if it is a directory, keep searching and search that directory for read / write files as well. Small example:

for(int i=0;i<fileList.length;i++){

   File fileListFile = fileList[i];
   boolean isReadable = fileListFile.canRead();
   boolean isWritable = fileListFile.canWrite();
   boolean isDir = fileListFile.isDirectory();

}

      

This is just an example that should lead you in the right direction. This must be done if you want to list the read / write files or directories.

+1


source







All Articles