0

I am trying to create a folder inside Internal Storage on Button click, but I can't figure out why it's not working.

backUp.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View view) {

        File sub = new File(MainActivity.this.getFilesDir(), "new_folder");
        if (!sub.exists()){
            sub.mkdirs();
            Toast.makeText(getApplicationContext(), "Sucess!!",
                        Toast.LENGTH_LONG).show();
        }

    }
});

Looks alright, displays the sucess toast but can't see the folder in directory. Even tried refreshing the Directory with:

  MediaScannerConnection.scanFile(MainActivity.this, new String[] {sub.toString()}, null, null);

Also provided WRITE_INTERNAL_STORAGE permission in Menifest.

<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />

0 Answers0