Skip to main content

Content Provider

Content Provider 

  • Introduction to android content providers in Hindi  
  • Accessing android content providers in Hindi
  • Creating android content providers in Hindi

Introduction to Content Provider

यदि आप अपनी application का डेटा दूसरी applications के साथ share करना चाहते है तो आपको अपनी application में content provider create करना होगा।

Content providers डेटा के access को manage करते है। Content providers डेटा को encapsulate करते है और डेटा को दूसरी application से security provide करते है।

android-content-provider-in-hindi


Content Provider create करने के लिए आपको Content-Provider class को extend करना होगा। जो class Content-Provider क्लास को extend करती है उसके ऑब्जेक्ट को provider object कहते है. जब आप content provider से data access करना चाहते है तो इसके लिए आपको Content-Resolver क्लास का object यूज़ करना होगा। Content provider से डेटा आप एक client की तरह access करते है। Content-Resolver provider object से communicate करता है.

एक content provider दूसरी applications को डेटा tables की form में present करता है। जिसमे row डेटा के type को represent करती है और column data के एक part को represent करता है।

कोई भी application जब किसी दूसरी application से डेटा access करना चाहती है तो वो Content-Resolver के माध्यम से एक client की तरह दूसरी application के provider object को request भेजती है। इसके बाद provider object request पर action लेता है, और results वापस भेजता है। ये किसी database से query करने जैसा ही है।

यदि आप दूसरी applications के साथ data share नहीं करना चाहते है तो आपको content provider create करने के आवश्यकता नहीं है। लेकिन यदि आप अपनी ही एप्लीकेशन में डेटा को search करना चाहते है तो आपको content provider की जरुरत होगी।

Accessing Content Provider

जैसे की मेने आपको पहले बताया content provider से डेटा access करने के लिए आपको Content-Resolver class का object यूज़ करना होता है। Content-Resolver object में कुछ methods होते है जो provider object में same नाम के methods को कॉल करते है। Content-Resolver object के methods के साथ आप डेटा के साथ basic operations जैसे की create, retrieve, update और delete परफॉर्म कर सकते है।

Content-Resolver में भी वही methods होते है जो Content-Provider में होते है। इसलिए जब आप Content-Resolver से कोई method कॉल करते है तो वो method same नाम के मेथड को Content-Provider में कॉल करता है।

उदाहरण के लिए आपकी application content को access करने के लिए Content-Resolver
से query() method कॉल करती है तो ये मेथड जो Content-Provider के query() method को कॉल करेगा। Content provider में यूज़ होने वाले methods नीचे दिए जा रहे है।


Content provider में बहुत सा डेटा available रहता है आप कोनसा data access करना चाहते है ये आपको खुद define करना होता है। इसके लिए आप content U-R-I का का यूज़ करेंगे। Content U-R-I वो U-R-I होता है जो content provider में डेटा को identify करता है। Content U-R-I में पहले आप content provider का नाम देते है फिर आप जो table access करना चाहते है उसका नाम देते है।   

Comments

Popular posts from this blog

Android Services

Android Services Introduction to  android services in Hindi  Declaring  services in Hindi Creating a  android service in Hindi Introduction to Android Services इससे पहले की आप जाने की service क्या होती है आइये जानते है की service क्या नहीं होती है - एक service separate प्रोसेस नहीं होती है। ये आपकी एप्लीकेशन का ही पार्ट होती है।  एक service thread नहीं होती है।  आइये अब देखते है service क्या होती है - Service एक facility होती है जिससे आप android system को बता सकते है की आप कोई काम background में करते रहना चाहते है।  Service एक facility होती है जिससे एक एप्लीकेशन अपनी कुछ functionality दूसरी applications को expose कर सकती है।    हर service क्लास का <service> declaration AndroidManifest.xml file में होना चाहिए। Services को आप context.startService() और context.bindService() मेथड्स से स्टार्ट कर सकते है।            जब service component क्रिएट होता है तो android syst...

Android Activity

Android Activity Activity life cycle in Hindi Starting an  android activity in Hindi Creating a new activity in Hindi Destroying an  android activity in Hindi Introduction to Activity आप की application में एक से ज्यादा activity हो सकती है। जब आप इन activities के through navigate करते है, यानि एक activity से दूसरी activity में जाते है तो activity अपनी life cycle की different stages में जाती है। उदाहरण के लिए जब आपकी activity start होती है तो ये foreground में होती है और user का पूरा focus इस पर होता है। इस process के दौरान  android  system कुछ life cycle methods को call करता है। यदि user कोई दूसरी activity start करता है तो android system उस activity के life cycle methods को call करता है और आपकी पहले वाली activity background में चली जाती है। life cycle methods में आप decide कर सकते है की जब user जाता है या वापस आता है तो आपकी activity कैसे behave करेगी।  उदाहरण के लिए यदि आप एक वीडियो player बना रहे है तो जब user किसी दूसरी activity पर जाये तो...

Android Spinners

Android Spinners  Introduction to  android spinners in Hindi Defining  android spinners in Hindi Creating spinner items array in Hindi Responding to spinner selections in Hindi    Introduction to Android Spinners Android spinners आपकी एप्लीकेशन में एक drop down menu होती है। इस drop down menu में बहुत से items होते है जिन्हे user choices कहते है। जब user spinner पर क्लिक करता है तो ये items शो होते है। यूज़र अपने लिए appropriate choice choose करता है। By default spinner में सबसे top वाला element शो होता है। Spinners को XML layout file में क्रिएट किया जाता है। और items की लिस्ट string resource file में क्रिएट की जाती है। जिसमे आप एक string array क्रिएट करते है।  Spinner और items को जोड़ने के लिए एक array adapter क्रिएट किया जाता है। इसके बाद selection events को respond करने के लिए OnItemSelectedListener interface को  इम्प्लीमेंट किया जाता है।  Defining Android Spinners Android spinners को आप XML l...