In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to use contentresolver", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use contentresolver" this article.
Contentresolver content provider is a tool for Android cross-program data exchange, which provides a complete mechanism. Allow one program to access the data of another program, while ensuring the security of the accessed data, you can choose part of the data to share. This article introduces its basic usage and related matters.
Contentresolver Runtime permission request
Above Android7.0, permissions are divided into normal permissions and dangerous permissions, and dangerous permissions need to be applied dynamically. The application steps are as follows:
Check whether the permission has been obtained by using the checkSelfPermission () method of ContextCompat
If the permission is not obtained, use the requestPerssion () method of ActivityCompat to apply for permission.
Rewrite the onRequestPermissionResult () method to process the application result.
PublicclassContentResolverTestActivityextendsAppCompatActivity {
@ Override
ProtectedvoidonCreate (BundlesavedInstanceState) {
Super.onCreate (savedInstanceState)
SetContentView (R.layout.activity_content_resolver_test)
/ / the first step
If (ContextCompat.checkSelfPermission (this,Manifest.permission.READ_CONTACTS))
! = PackageManager.PERMISSION_GRANTED) {
/ / in the second step, the third parameter can transfer a unique value
ActivityCompat.requestPermissions (this
NewString [] {Manifest.permission.READ_CONTACTS}
1)
} else {
/ / Business logic after obtaining permission
}
}
Contentresolver reads data from other programs
Apply for relevant permissions dynamically
Using the getContentResolver () method of Context to obtain ContentResovler
Execute the query method of ContentResovler to get a Cursor object
Process the obtained Cursor
The above is all the contents of this article "how to use contentresolver". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 213
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.