I am trying to share a folder in my mobile device to google drive .But I am getting the error upload was unsuccessful,request contained no data google drive from mobile app
I could share the folder through whatsapp without any issues.
My Code-
File directory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File folderData = new File(directory + "/Stocks/" + "Branch/" + "Test");
String folderPath = folderData.getPath();
Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
intent.setType("*/*");
// Get the list of files in the folder
File folder = new File(folderPath);
File[] files = folder.listFiles();
// Create an ArrayList to hold the file Uri objects
ArrayList<Uri> fileUris = new ArrayList<>();
// Loop through the files and add their Uri to the ArrayList
for (int i = 0; i < files.length; i++) {
File file = files[i];
Uri uri = Uri.fromFile(file);
fileUris.add(uri);
}
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("*/*");
shareIntent.putExtra(Intent.EXTRA_STREAM,fileUris);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, null));
I am having 2 files in the folder test,so thet uris are 1.file:///storage/emulated/0/Download/Stocks/g/test/test.txt 2.file:///storage/emulated/0/Download/Stocks/g/test/stockdetails.xls :(