Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android sharing Files, by sending them via email or other apps

I have a list of files in my android app and I want to be able to get the selected items and send them via email or any other sharing app. Here is my code.

Intent sendIntent = new Intent();                     sendIntent.setAction(Intent.ACTION_SEND);                     sendIntent.putExtra(Intent.EXTRA_EMAIL, getListView().getCheckedItemIds());                     sendIntent.setType("text/plain");                     startActivity(sendIntent); 
like image 412
user2351234 Avatar asked Aug 01 '13 05:08

user2351234


People also ask

Which app is used to share files?

AirDroid (Android) AirDroid for Android offers a feature-packed interface in your browser for sending files and installing apps. There's a full-fledged file manager to share files from your desktop to your device and vice versa, as well as dedicated tools to view photos and play music from local storage.

How do I share files between apps on Android?

One way a sending app can share a file is to respond to a request from the receiving app. In all cases, the only secure way to offer a file from your app to another app is to send the receiving app the file's content URI and grant temporary access permissions to that URI.


2 Answers

this is the code for sharing file in android

Intent intentShareFile = new Intent(Intent.ACTION_SEND); File fileWithinMyDir = new File(myFilePath);  if(fileWithinMyDir.exists()) {     intentShareFile.setType("application/pdf");     intentShareFile.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+myFilePath));      intentShareFile.putExtra(Intent.EXTRA_SUBJECT,                         "Sharing File...");     intentShareFile.putExtra(Intent.EXTRA_TEXT, "Sharing File...");      startActivity(Intent.createChooser(intentShareFile, "Share File")); } 
like image 88
Tushar Mate Avatar answered Sep 19 '22 23:09

Tushar Mate


sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(exportPath)); 

also you can make zip file of all file and attach zip file for send multiple file in android

like image 31
Digvesh Patel Avatar answered Sep 22 '22 23:09

Digvesh Patel