अरबों लोगों के लिए डेटा की लागत कम हो गई
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
कुछ देशों में डेटा प्लान की कीमत, आम तौर पर उपयोगकर्ता की महीने की आय के 10% से ज़्यादा हो सकती है. इसका मतलब है कि ऐप्लिकेशन के डाउनलोड साइज़ को कम करने और उपयोगकर्ता को यह कंट्रोल देने से कि आपका ऐप्लिकेशन डेटा का इस्तेमाल कैसे करता है, कई लोगों को इसका फ़ायदा मिल सकता है. डाउनलोड का साइज़ कम होने से, इंटरनल स्टोरेज में जगह भी बचती है. कुछ डिवाइसों में इंटरनल स्टोरेज कम होता है.
यहां कुछ रणनीतियां दी गई हैं. इनकी मदद से, आपके ऐप्लिकेशन के नेटवर्क और इंटरनल स्टोरेज, दोनों में इस्तेमाल होने वाले डेटा की मात्रा को ऑप्टिमाइज़ किया जा सकता है.
ऐप्लिकेशन का साइज़ कम करना
ऐप्लिकेशन का साइज़ कम करना, एक बुनियादी तरीका है. इससे उपयोगकर्ता को नेटवर्क डेटा और इंटरनल स्टोरेज, दोनों के मामले में कम डेटा इस्तेमाल करने में मदद मिलती है. इस सेक्शन में, ऐप्लिकेशन का साइज़ कम करने के कई तरीके बताए गए हैं.
APK की ग्राफ़िकल ऐसेट का साइज़ कम करना
- ग्राफ़िकल ऐसेट की वजह से, अक्सर APK का साइज़ सबसे ज़्यादा होता है. इन्हें ऑप्टिमाइज़ करने से, ऐप्लिकेशन का साइज़ कम हो जाता है. इससे, उपयोगकर्ता के लिए ऐप्लिकेशन को डाउनलोड और इंस्टॉल करने में कम समय लगता है.
- आइकॉन जैसी ग्राफ़िकल ऐसेट के लिए, स्केलेबल वेक्टर ग्राफ़िक्स (SVG) फ़ॉर्मैट का इस्तेमाल करें. SVG इमेज, बिटमैप ग्राफ़िक्स की तुलना में साइज़ में बहुत छोटी होती हैं. इन्हें किसी भी रिज़ॉल्यूशन पर रेंडर किया जा सकता है. Android Support Library, Android 2.1 (एपीआई लेवल 7) के लिए, वेक्टर रिसॉर्स को पुराने सिस्टम के साथ काम करने की सुविधा देती है.
इस Medium पोस्ट की मदद से, वेक्टर का इस्तेमाल शुरू करें.
- फ़ोटो जैसी नॉन-वेक्टर इमेज के लिए, WebP का इस्तेमाल करें. इससे इमेज लोड होने में लगने वाला समय कम हो जाता है और नेटवर्क बैंडविड्थ भी बचती है. WebP, PNG और JPG फ़ॉर्मैट की तुलना में कम साइज़ की फ़ाइलें बनाता है. साथ ही, इसकी इमेज क्वालिटी कम से कम उतनी ही होती है. लॉसी सेटिंग में भी, WebP फ़ॉर्मैट में ओरिजनल इमेज के जैसी इमेज तैयार की जा सकती है. Android 4.0 (एपीआई लेवल 14: आइसक्रीम सैंडविच) से ही, Android में लॉस वाले WebP फ़ॉर्मैट का इस्तेमाल किया जा सकता है. वहीं, Android 4.2 (एपीआई लेवल 17: Jelly Bean) से, बिना लॉस वाले और पारदर्शी WebP फ़ॉर्मैट का इस्तेमाल किया जा सकता है.
- अगर आपके पास अलग-अलग डेंसिटी वाली कई बड़ी इमेज हैं, तो डेंसिटी के हिसाब से अपने APK को बाँटने के लिए, एक से ज़्यादा APK इस्तेमाल करने की सुविधा का इस्तेमाल करें. इससे, खास डेनसिटी के लिए टारगेट किए गए बिल्ड मिलते हैं. इसका मतलब है कि कम डेनसिटी वाले डिवाइसों का इस्तेमाल करने वाले लोगों को, इस्तेमाल न की गई ज़्यादा डेनसिटी वाली ऐसेट डाउनलोड करने का जुर्माना नहीं देना पड़ेगा.
- APK का साइज़ कम करने के बारे में ज़्यादा जानने के लिए, APK का साइज़ कम करना और अपने कोड और संसाधनों का साइज़ कम करना लेख पढ़ें. इसके अलावा, APK का साइज़ कम करने के बारे में ज़्यादा जानकारी के लिए,
मीडियम पोस्ट की इस सीरीज़ को पढ़ें.
कोड का साइज़ कम करना
- आपके Android प्रोजेक्ट में मौजूद हर लाइब्रेरी, APK में ऐसा कोड जोड़ रही है जिसका इस्तेमाल नहीं किया जा रहा है. एक्सटर्नल लाइब्रेरी का इस्तेमाल करते समय खास तौर पर सावधानी बरतें, क्योंकि सभी लाइब्रेरी मोबाइल ऐप्लिकेशन में इस्तेमाल करने के लिए नहीं बनाई गई हैं. पक्का करें कि आपके ऐप्लिकेशन में इस्तेमाल की जा रही लाइब्रेरी, मोबाइल पर इस्तेमाल के लिए ऑप्टिमाइज़ की गई हों.
- ProGuard जैसे टूल का इस्तेमाल करके, अपने कंपाइल किए गए कोड को ऑप्टिमाइज़ करें. ProGuard, ऐसे कोड की पहचान करता है जिसका इस्तेमाल नहीं किया जा रहा है. इसके बाद, वह उसे आपके APK से हटा देता है. इसके अलावा, बिल्ड के समय
संसाधन कम करने की सुविधा चालू करें. इसके लिए,
build.gradle
में minifyEnabled=true
, shrinkResources=true
सेट करें. इससे आपके APK से, इस्तेमाल न होने वाले संसाधन अपने-आप हट जाते हैं.
- Google Play सेवाओं का इस्तेमाल करते समय, आपको अपने APK में सिर्फ़ ज़रूरी एपीआई
शामिल करने चाहिए.
- अपने APK में कोड का साइज़ कम करने के बारे में ज़्यादा जानने के लिए, Android की ट्रेनिंग देखें. इसमें डिपेंडेंसी इंजेक्शन फ़्रेमवर्क से बचने का तरीका बताया गया है.
ऐप्लिकेशन को बाहरी (एसडी) स्टोरेज में ले जाने की अनुमति दें
- कम कीमत वाले डिवाइसों में अक्सर कम स्टोरेज होता है. उपयोगकर्ता, एसडी कार्ड की मदद से इसे बढ़ा सकते हैं. हालांकि, ऐप्लिकेशन को साफ़ तौर पर यह एलान करना होगा कि वे बाहरी स्टोरेज में इंस्टॉल किए जा सकते हैं. इसके बाद ही, उपयोगकर्ता उन्हें बाहरी स्टोरेज में ले जा सकते हैं.
- अपने ऐप्लिकेशन को बाहरी स्टोरेज में इंस्टॉल करने की अनुमति दें. इसके लिए, AndroidManifest.xml में
android:installLocation
फ़्लैग का इस्तेमाल करें. अपने ऐप्लिकेशन को बाहरी स्टोरेज में ले जाने की सुविधा चालू करने के बारे में ज़्यादा जानने के लिए, ऐप्लिकेशन इंस्टॉल करने की जगह के बारे में Android गाइड देखें.
ऐप्लिकेशन इंस्टॉल होने के बाद, डिस्क का इस्तेमाल कम करना
- आपके ऐप्लिकेशन के लिए डिस्क का इस्तेमाल कम होने का मतलब है कि जब डिवाइस में खाली जगह कम होती है, तो उपयोगकर्ता आपके ऐप्लिकेशन को अनइंस्टॉल नहीं करते हैं. अपनी कैश मेमोरी के लिए सीमाएं तय करना ज़रूरी है. इससे आपके ऐप्लिकेशन के डिस्क इस्तेमाल को अनिश्चित काल तक बढ़ने से रोका जा सकता है. पक्का करें कि आपने कैश मेमोरी में सेव किया गया डेटा,
getCacheDir()
में रखा हो. सिस्टम, ज़रूरत के हिसाब से यहां रखी गई फ़ाइलों को मिटा सकता है. इसलिए, ये फ़ाइलें ऐप्लिकेशन के लिए तय किए गए स्टोरेज में नहीं दिखेंगी.
नेटवर्क के इस्तेमाल को कॉन्फ़िगर करने की सुविधा देना
Android प्लैटफ़ॉर्म पर, उपयोगकर्ताओं को आपके ऐप्लिकेशन के नेटवर्क इस्तेमाल पर कंट्रोल देने के कई तरीके उपलब्ध हैं. इससे, वे अपनी ज़रूरतों के हिसाब से ऐप्लिकेशन को ऑप्टिमाइज़ कर सकते हैं. उदाहरण के लिए,
पहली बार इस्तेमाल करने पर, आपका ऐप्लिकेशन उपयोगकर्ता को नेटवर्क से जुड़ी कई सेटिंग के बारे में जानकारी दे सकता है.
ऐप्लिकेशन के बाहर से भी नेटवर्क की प्राथमिकताओं वाली स्क्रीन दी जा सकती है.
उपयोगकर्ताओं को उनके नेटवर्क से जुड़ी प्राथमिकताओं के हिसाब से, ऐप्लिकेशन इस्तेमाल करने का तरीका बताना
- उपयोगकर्ताओं को डेटा का इस्तेमाल कम करने की सुविधा देने वाले ऐप्लिकेशन को काफ़ी पसंद किया जाता है. भले ही, उन्हें ज़्यादा डेटा की ज़रूरत हो. अगर आपका ऐप्लिकेशन काफ़ी बैंडविड्थ का इस्तेमाल करता है (उदाहरण के लिए, वीडियो स्ट्रीमिंग ऐप्लिकेशन), तो उपयोगकर्ताओं को नेटवर्क इस्तेमाल करने की सुविधा कॉन्फ़िगर करने के लिए, ऑनबोर्डिंग का अनुभव दिया जा सकता है. उदाहरण के लिए, उपयोगकर्ता को सेल्यूलर नेटवर्क पर कम बिटरेट वाली वीडियो स्ट्रीम को ज़बरदस्ती चलाने की अनुमति दी जा सकती है.
- उपयोगकर्ताओं के लिए अतिरिक्त सेटिंग उपलब्ध कराएं. इनकी मदद से, वे डेटा सिंक करने, प्रीफ़ेच करने, और नेटवर्क इस्तेमाल करने के तरीके को कंट्रोल कर सकते हैं. उदाहरण के लिए, सिर्फ़ वाई-फ़ाई पर स्टार की गई सभी खबरों की कैटगरी को प्रीफ़ेच करना. इससे उपयोगकर्ताओं को अपनी ज़रूरतों के हिसाब से, आपके ऐप्लिकेशन के व्यवहार को तय करने में मदद मिलती है.
- नेटवर्क के इस्तेमाल को मैनेज करने के बारे में ज़्यादा जानने के लिए, Android की ट्रेनिंग में नेटवर्क के इस्तेमाल को मैनेज करने के बारे में जानकारी देखें.
नेटवर्क की प्राथमिकताओं वाली स्क्रीन उपलब्ध कराना
- नेटवर्क की प्राथमिकताओं वाली स्क्रीन का इस्तेमाल करके, ऐप्लिकेशन के बाहर से भी ऐप्लिकेशन की नेटवर्क सेटिंग पर जाया जा सकता है. इस स्क्रीन को सिस्टम सेटिंग स्क्रीन या सिस्टम डेटा के इस्तेमाल की स्क्रीन से ऐक्सेस किया जा सकता है.
- नेटवर्क की प्राथमिकताओं वाली स्क्रीन उपलब्ध कराने के लिए, अपने ऐप्लिकेशन में ऐसी गतिविधि शामिल करें जो
ACTION_MANAGE_NETWORK_USAGE
कार्रवाई का समर्थन करती हो. इस स्क्रीन को उपयोगकर्ता, आपके ऐप्लिकेशन के साथ-साथ सिस्टम सेटिंग से भी ऐक्सेस कर सकते हैं.
- नेटवर्क की प्राथमिकताओं वाली स्क्रीन जोड़ने के बारे में ज़्यादा जानने के लिए,
Implementing a Preferences Activity के बारे में Android ट्रेनिंग देखें.
अन्य संसाधन
इस विषय के बारे में ज़्यादा जानने के लिए, यहां दिए गए अन्य संसाधन देखें:
ब्लॉग पोस्ट
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. 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,["# Reduced data cost for billions\n\n\u003cbr /\u003e\n\n\nData plans in some countries can cost upwards of 10% of a typical user's monthly income. This\nmeans that minimizing your app's download size and letting the user control how your app uses\ndata can have a large, tangible benefit to many users. Minimizing download size also helps\nconserve space in internal storage, which is a scarce resource in some devices.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\nHere you can find some strategies to help optimize the amount of data your app uses, both over\nthe network and in internal storage.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nReduce app size\n---------------\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\nReducing app size is one of the fundamental ways you can help your user consume less data, in\nterms of both network data and internal storage. This section describes several approaches to\nreducing app size.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### Reduce APK graphical asset size\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n- Graphical assets are often the largest contributor to the size of the APK. Optimizing these can result in smaller downloads and thus faster installation times for users.\n- For graphical assets such as icons, use the Scalable Vector Graphics (SVG) format. SVG images are tiny in size compared to bitmap graphics and can be rendered at runtime to any resolution. The [Android Support Library](/tools/support-library) provides a backward-compatible implementation for vector resources to Android 2.1 (API level 7). Get started with vectors with [this Medium post](https://medium.com/@chrisbanes/appcompat-v23-2-age-of-the-vectors-91cbafa87c88).\n- For non-vector images, such as photos, use [WebP](https://developers.google.com/speed/webp/) to reduce image load times and save network bandwidth. WebP is proven to result in smaller file sizes than its PNG and JPG counterparts, with at least the same image quality. Even at lossy settings, WebP can produce a nearly identical image to the original. Android has included lossy WebP support since Android 4.0 (API level 14: Ice Cream Sandwich) and support for lossless, transparent WebP since Android 4.2 (API level 17: Jelly Bean).\n- If you have many large images across multiple densities, consider using [Multiple\n APK support](/google/play/publishing/multiple-apks) to split your APK by density. This results in builds targeted for specific densities, meaning users with low-density devices won't have to incur the penalty of downloading unused high-density assets.\n- For more information about reducing APK size, see [Reduce APK Size](/topic/performance/reduce-apk-size) and [Shrink Your Code and Resources](/studio/build/shrink-code). In addition, you can find a detailed guide on reducing APK size in this [series of Medium posts](https://medium.com/@wkalicinski/smallerapk-part-4-multi-apk-through-abi-and-density-splits-477083989006).\n\n### Reduce code size\n\n- Every library in your Android project is adding potentially unused code to the APK. Be particularly careful about using external libraries because not all libraries are designed for use in mobile apps. Ensure that the libraries your app is using are optimized for mobile use.\n- Consider optimizing your compiled code using a tool such as [ProGuard](/tools/help/proguard). ProGuard identifies code that isn't being used and removes it from your APK. Also [enable resource shrinking](http://tools.android.com/tech-docs/new-build-system/resource-shrinking) at build time by setting `minifyEnabled=true`, `shrinkResources=true` in `build.gradle`---this automatically removes unused resources from your APK.\n- When using Google Play services, you should [selectively include](/google/play-services/setup#add_google_play_services_to_your_project) only the necessary APIs into your APK.\n- For more information on reducing code size in your APK, see the Android training on how to [Avoid\n dependency injection frameworks](/training/articles/memory#DependencyInjection).\n\n### Allow app to be moved to external (SD) storage\n\n- Low-cost devices often come with little on-device storage. Users can extend this with SD cards; however, apps need to explicitly declare that they support being installed to external storage before users can move them.\n- Allow your app to be installed to external storage using the [`\n android:installLocation`](/guide/topics/manifest/manifest-element#install) flag in your AndroidManifest.xml. For more information on enabling your app to be moved to external storage, see the Android guide on [App Install\n Location](/guide/topics/data/install-location).\n\n\u003cbr /\u003e\n\n### Reduce post-install app disk use\n\n\u003cbr /\u003e\n\n- Keeping your app's disk use low means that users are less likely to uninstall your app when the device is low on free space. It's important to apply bounds around your caches---this prevents your app's disk use from growing indefinitely. Be sure you put your cached data in [getCacheDir()](/reference/android/content/Context#getCacheDir())---the system can delete files placed here as needed, so they won't show up as storage committed to the app.\n\n\u003cbr /\u003e\n\nOffer configurable network use\n------------------------------\n\n\nThe Android platform includes a number of ways you can give the user control\nover your app's network use, optimizing it for their own needs. For example,\non first use, your app can walk the user through a variety of network-related settings.\nYou can also provide a network preferences screen from outside the app.\n\n### Provide onboarding experiences for users' network\nchoices\n\n\u003cbr /\u003e\n\n- Apps that allow users to reduce data use are well received, even if they have heavy data requirements. If your app uses a considerable amount of bandwidth (for example, video streaming apps), you can provide an onboarding experience for users to configure network use. For example, you could allow the user to force lower-bitrate video streams on cellular networks.\n- Additional settings for users to control data syncing, prefetching, and network use behavior (for example, prefetch all starred news categories on Wi-Fi only), also help users tailor your app's behavior to their needs.\n- For more information on managing network use, see the Android training on [Managing\n Network Usage](/training/basics/network-ops/managing).\n\n### Provide a network preferences\nscreen\n\n- You can navigate to the app's network settings from outside the app by means of a network preferences screen. You can invoke this screen from either the system settings screen or the system data usage screen.\n- To provide a network preferences screen that users can access from within your app as well as from the system settings, in your app include an activity that supports the [ACTION_MANAGE_NETWORK_USAGE](/reference/android/content/Intent#ACTION_MANAGE_NETWORK_USAGE) action.\n- For further information on adding a network preferences screen, see the Android training on [Implementing a Preferences Activity](/training/basics/network-ops/managing#prefs).\n\n\u003cbr /\u003e\n\nAdditional resources\n--------------------\n\nTo learn more about this topic, view the following additional resources:\n\n### Blog posts\n\n- [Nurture trust through cost transparency](https://medium.com/google-design/nurture-trust-through-cost-transparency-b61a5947d2fc)"]]