Android Studio Save Audio With MediaStore (Android 11)

0
42
 String videoFileName = "video_" + System.currentTimeMillis() + ".mp3";
        ContentValues valuesvideos = new ContentValues();
        valuesvideos.put(MediaStore.Audio.Media.RELATIVE_PATH, Environment.DIRECTORY_MUSIC + "/AudFolder");
        valuesvideos.put(MediaStore.Audio.Media.TITLE, videoFileName);
        valuesvideos.put(MediaStore.Audio.Media.DISPLAY_NAME, videoFileName);
        valuesvideos.put(MediaStore.Audio.Media.MIME_TYPE, "audio/mpeg");
        valuesvideos.put(MediaStore.Audio.Media.DATE_TAKEN, System.currentTimeMillis());
        valuesvideos.put(MediaStore.Audio.Media.IS_PENDING, 1);
        final Uri collection = MediaStore.Audio.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
        Uri uriSavedAudio = getActivity().getContentResolver().insert(collection, valuesvideos);
        String destPath = getDestinationPath();
        Log.e(TAG, "saveAudioToDevice: Destination Path (Below android 10) = "+destPath );
        try {
            ParcelFileDescriptor pfdAudio = getActivity().getContentResolver().openFileDescriptor(uriSavedAudio, "w");
  
FileDescriptor audioFd = pfdVideo.getFileDescriptor();

        } catch (IOException e) {
            e.printStackTrace();
            Log.e(TAG, "saveAudioToDevice: ERROR = "+ e.getMessage() );
        }

LEAVE A REPLY

Please enter your comment!
Please enter your name here