0

I'm working on a status saver app that works on all devices except Android 11. I also updated the route, but it still works with the manage external storage permission, which I don't want to use because my app was rejected by Google. Is there any way to get WhatsApp status copied into a hidden folder in Android 11?

if (Build.VERSION.SDK_INT >= 29) {
        targetPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/media/com.whatsapp/WhatsApp/Media/.Statuses";

    }
    else{
        targetPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/WhatsApp/Media/.Statuses";

    }
Wowo Ot
  • 1,362
  • 13
  • 21
Abbasi
  • 84
  • 7

2 Answers2

0

In the new Android Devices API 30 and newer you can only write in your app-specific files

File directory = new File(context.getFilesDir(), "YOUR_DIR");
directory.mkdirs();

or in the external storage of your app Android/data

File directory = new File(myContext.getExternalFilesDir("FolderName"),"YOUR_DIR");
Wowo Ot
  • 1,362
  • 13
  • 21
  • 1
    Every app can also create folders and files in all public directories on external storage. Please try. – blackapps Sep 05 '21 at 10:57
0

On Android 11, You will need to work with android shared storage permission. You can use the below code to request permission.

    private void checkWhatsAppPermission(){
    // Choose a directory using the system's file picker.
    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
    // Optionally, specify a URI for the directory that should be opened in
    // the system file picker when it loads.

    Uri wa_status_uri = Uri.parse("content://com.android.externalstorage.documents/tree/primary%3AAndroid%2Fmedia/document/primary%3AAndroid%2Fmedia%2Fcom.whatsapp%2FWhatsApp%2FMedia%2F.Statuses");
    intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, wa_status_uri);
    startActivityForResult(intent, 10001);
 }

https://play.google.com/store/apps/details?id=com.larntech.whatsappstatussaver

Richard Kamere
  • 749
  • 12
  • 10