Search code examples
androidreact-nativewhatsappstatusandroid-11

Android 11 not showing WhatsApp status in app. /storage/emulated/0/WhatsApp/Media/.Statuses/ folder shows empty result


I have facing issue related to Android 11 in React Native. In my app, i am fetching WhatsApp status from /storage/emulated/0/WhatsApp/Media/.Statuses/ folder everything working find till Android 10, but in android 11 it shows nothing. Please guild me for this.

Here is my react native code to read WhatsApp status folder

  var RNFS = require('react-native-fs');
        RNFS.readDir(RNFS.ExternalStorageDirectoryPath + '/WhatsApp/Media/.Statuses/').then((result) => {
             printLogs("Result=>", result);
             result.map((item)=>{
                 printLogs("path===>",item.path)
             })
            setStatusList(result.sort((a, b) => a.mtime < b.mtime ? 1 : -1));
            setRefresh(false);

        }).catch((error) => {
            printLogs("error=>", error);
            setRefresh(false);
            setStatusList([]);

        })

Solution

  • On an Android 11 device your app has access to the folder you mention but it will not see files that belong to other apps. Only subfolders.

    So the owner of the file is important on an Android 11 device.

    For testing at home you can request all files access with MANAGE_EXTERNAL_STORAGE.

    See: Accessing external storage in Android API 29