I created a some lines in order to create a directory on the mainActivity class
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
// Show an expanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_READ_CONTACTS);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
And
File tSubLogDirectory = new File(Environment.getExternalStorageDirectory()+File.separator+"data");
if(!tSubLogDirectory.exists())
tSubLogDirectory.mkdirs();
if(tSubLogDirectory.exists())
System.out.println("Created ");
set permission lines in the android manifest file in order to allow writing/reading files on the external storage
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ny_project.blue">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application...
but still the output I get indicates that the directory did not created
I/System.out: ***********************************************************
I/System.out: /storage/emulated/0/data
I/System.out: ***********************************************************
I have also looked in storage/emulated/0/data directory in order to see if by mistake the file is in, but no, it is not.
can someone tell me please what I am doing wrong ?