Search code examples
javaandroidandroid-studioandroid-11scoped-storage

How to use .status folder for WhatsApp status saver app in android 11 scoped storage?


Hey guys I had made a WhatsApp status saver app. But in android 11, Google introduced scoped storage so I'm not getting status of the user in the app. For that I have used MANAGE_EXTERNAL_STORAGE but with this I can't publish the app in Google play. I've seen few apps using some permission to grant access to use that .status folder. How to do that ? I have attached the screenshot of the permission that the app was asking. I am a beginner so please help me out.

Screenshot


Solution

  • Request the user to give permission to the WhatsApp status storage folder.

    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);
    }
    

    You can check a working example using above method here. https://play.google.com/store/apps/details?id=com.larntech.whatsappstatussaver