Difference between Shared Preferences and Content Providers in android
Asked Answered
L

2

8

I know partially about Shared preferences and intents.But i want to know what are shared preferences and content providers in android ? And also what is the basic difference between intents , shared preferences and content providers.

Please explain me this.

Lentigo answered 13/12, 2011 at 12:6 Comment(2)
you should read some documentantion first and then ask if you have a specific uncertainty about somethingLouisville
yup i have read it but i am getting confused so i asked please clear my confusion on thisLentigo
B
14

shared preferences are the location where you can store the secret information for your app, like setting cookies in the browser, this can be used for login credentials and other.

where as content provider stores and retrieves the data and make it available to other applications also. like suppose you want to access the contacts available in the android phone, they can be accessed by content providers

Bondswoman answered 13/12, 2011 at 12:15 Comment(2)
what do you mean by differentiate, you need theoritical knowledge for it, or wanted to use in some code, please clarify the exact requirement first.Bondswoman
developer.android.com/guide/topics/data/data-storage.html ,,,,,,,,, developer.android.com/guide/topics/providers/…Bondswoman
L
5

SharedPreferences

SharedPreferences is a key/value store where you can save a data under certain key. To read the data from the store you have to know the key of the data. This makes reading the data very easy. But as easy as it is to store a small amount of data as difficult it is to store and read large structured data as you need to define key for every single data, furthermore you cannot really search within the data except you have a certain concept for naming the keys.

Content providers

Content providers manage access to a structured set of data. They encapsulate the data, and provide mechanisms for defining data security. Content providers are the standard interface that connects data in one process with code running in another process.

You don't need to develop your own provider if you don't intend to share your data with other applications. However, you do need your own provider to provide custom search suggestions in your own application. You also need your own provider if you want to copy and paste complex data or files from your application to other applications.

Android itself includes content providers that manage data such as audio, video, images, and personal contact information.

Loot answered 3/9, 2014 at 12:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.