फ़ाइलें शेयर करना
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
अक्सर, ऐप्लिकेशन को अपनी एक या उससे ज़्यादा फ़ाइलें किसी दूसरे ऐप्लिकेशन को उपलब्ध करानी पड़ती हैं. उदाहरण के लिए, हो सकता है कि कोई इमेज
गैलरी, इमेज एडिटर को फ़ाइलें उपलब्ध कराना चाहे या कोई फ़ाइल मैनेजमेंट ऐप्लिकेशन, उपयोगकर्ताओं को बाहरी स्टोरेज के अलग-अलग सेक्शन के बीच फ़ाइलें कॉपी और चिपकाने की अनुमति देना चाहे. फ़ाइल शेयर करने के लिए, फ़ाइल भेजने वाला ऐप्लिकेशन, फ़ाइल पाने वाले ऐप्लिकेशन के अनुरोध का जवाब दे सकता है.
किसी भी मामले में, अपने ऐप्लिकेशन से किसी दूसरे ऐप्लिकेशन को फ़ाइल भेजने का सबसे सुरक्षित तरीका यह है कि फ़ाइल पाने वाले ऐप्लिकेशन को फ़ाइल के कॉन्टेंट का यूआरआई भेजा जाए और उस यूआरआई को कुछ समय के लिए ऐक्सेस करने की अनुमतियां दी जाएं.
कुछ समय के लिए यूआरआई ऐक्सेस करने की अनुमतियां वाले कॉन्टेंट यूआरआई सुरक्षित होते हैं, क्योंकि ये सिर्फ़ उस ऐप्लिकेशन पर लागू होते हैं जिसे यूआरआई मिलता है. साथ ही, इनकी समयसीमा अपने-आप खत्म हो जाती है. Android
FileProvider
कॉम्पोनेंट, फ़ाइल के कॉन्टेंट यूआरआई को जनरेट करने के लिए,
getUriForFile()
तरीका उपलब्ध कराता है.
अगर आपको ऐप्लिकेशन के बीच कम टेक्स्ट या संख्या वाला डेटा शेयर करना है, तो आपको डेटा वाला
Intent
भेजना चाहिए. Intent
के साथ आसान डेटा भेजने का तरीका जानने के लिए, आसान डेटा शेयर करना ट्रेनिंग क्लास देखें.
इस क्लास में, Android FileProvider
कॉम्पोनेंट से जनरेट किए गए कॉन्टेंट यूआरआई का इस्तेमाल करके, अपने ऐप्लिकेशन से किसी दूसरे ऐप्लिकेशन में फ़ाइलें सुरक्षित तरीके से शेयर करने का तरीका बताया गया है. साथ ही, कॉन्टेंट यूआरआई के लिए, फ़ाइलें पाने वाले ऐप्लिकेशन को दी जाने वाली कुछ समय के लिए मान्य अनुमतियों के बारे में भी बताया गया है.
लेसन
- फ़ाइल शेयर करने की सुविधा सेट अप करना
-
फ़ाइलें शेयर करने के लिए, अपने ऐप्लिकेशन को सेट अप करने का तरीका जानें.
- फ़ाइल शेयर करना
-
फ़ाइल के लिए कॉन्टेंट यूआरआई जनरेट करके, किसी दूसरे ऐप्लिकेशन को फ़ाइल उपलब्ध कराने का तरीका जानें. इसके लिए, यूआरआई को ऐक्सेस करने की अनुमतियां दें और यूआरआई को ऐप्लिकेशन पर भेजें.
- शेयर की गई फ़ाइल का अनुरोध करना
-
किसी दूसरे ऐप्लिकेशन से शेयर की गई फ़ाइल का अनुरोध करने, फ़ाइल का कॉन्टेंट यूआरआई पाने, और फ़ाइल खोलने के लिए कॉन्टेंट यूआरआई का इस्तेमाल करने का तरीका जानें.
-
फ़ाइल की जानकारी हासिल करना
-
जानें कि कोई ऐप्लिकेशन,
FileProvider
से जनरेट किए गए कॉन्टेंट यूआरआई का इस्तेमाल करके, फ़ाइल की जानकारी कैसे हासिल कर सकता है. इसमें MIME टाइप और फ़ाइल का साइज़ शामिल है.
इस बारे में ज़्यादा जानकारी के लिए, यहां जाएं:
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया."],[],[],null,["# Sharing files\n\nApps often have a need to offer one or more of their files to another app. For example, an image\ngallery may want to offer files to image editors, or a file management app may want to allow\nusers to copy and paste files between areas in external storage. One way a sending app can\nshare a file is to respond to a request from the receiving app.\n\n\nIn all cases, the only secure way to offer a file from your app to another app is to send the\nreceiving app the file's content URI and grant temporary access permissions to that URI.\nContent URIs with temporary URI access permissions are secure because they apply only to the\napp that receives the URI, and they expire automatically. The Android\n[FileProvider](/reference/androidx/core/content/FileProvider) component provides the method\n[getUriForFile()](/reference/androidx/core/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)) for\ngenerating a file's content URI.\n\n\nIf you want to share small amounts of text or numeric data between apps, you should send an\n[Intent](/reference/android/content/Intent) that contains the data. To learn how to send simple data with an\n[Intent](/reference/android/content/Intent), see the training class\n[Sharing simple data](/training/sharing).\n\n\nThis class explains how to securely share files from your app to another app using content URIs\ngenerated by the Android [FileProvider](/reference/androidx/core/content/FileProvider) component and\ntemporary permissions that you grant to the receiving app for the content URI.\n\nLessons\n-------\n\n**[Setting up file sharing](/training/secure-file-sharing/setup-sharing)**\n:\n Learn how to set up your app to share files.\n\n**[Sharing a file](/training/secure-file-sharing/share-file)**\n:\n Learn how to offer a file to another app by generating a content URI for the file,\n granting access permissions to the URI, and sending the URI to the app.\n\n**[Requesting a shared file](/training/secure-file-sharing/request-file)**\n:\n Learn how to request a file shared by another app, receive the content URI for the file,\n and use the content URI to open the file.\n\n\n**[Retrieving file information](/training/secure-file-sharing/retrieve-info)**\n:\n Learn how an app can use a content URI generated by a\n [FileProvider](/reference/androidx/core/content/FileProvider) to retrieve file information including\n MIME type and file size.\n\nFor additional related information, refer to:\n\n- [Storage Options](/guide/topics/data/data-storage)\n- [Saving Files](/training/basics/data-storage/files)\n- [Sharing Simple Data](/training/sharing)"]]