Pro Android with Kotlin


CHAPTER 6: Content Providers


Download 5.42 Mb.
Pdf ko'rish
bet61/223
Sana04.11.2023
Hajmi5.42 Mb.
#1746807
1   ...   57   58   59   60   61   62   63   64   ...   223
Bog'liq
@de android telegram Pro Android with Kotlin Developing Modern Mobile

64
CHAPTER 6: Content Providers
// ----- Variant B -----
// You don't have to implement this. The default
// implementation calls variant A, but disregards the
// 'cancellationSignal' argument.
fun query(
uri:Uri,
projection:Array,
selection:String,
selectionArgs:Array,
String sortOrder:String,
cancellationSignal:CancellationSignal) : Cursor
// ----- Variant C -----
// You don't have to implement this. The default
// implementation converts the bundle argument to
// appropriate arguments for calling variant B.
// The bundle keys used are:
// ContentResolver.QUERY_ARG_SQL_SELECTION
// ContentResolver.QUERY_ARG_SQL_SELECTION_ARGS
// ContentResolver.QUERY_ARG_SQL_SORT_ORDER -or-
// ContentResolver.QUERY_ARG_SORT_COLUMNS
// (this being a String array)
fun query(
uri:Uri,
projection:Array,
queryArgs:Bundle,
cancellationSignal:CancellationSignal) : Cursor
These methods are not intended to present file data such as images and sound. Returning 
links or identifiers to file data is acceptable, though.
In the following list, I describe all the parameters by name and variant:

uri: This is an important parameter specifying the type coordinates of 
the query in the data space. Content consumers will tell what kind of 
data they are interested in by appropriately specifying this parameter. 
Since URIs are so important, we describe them in their own section; see 
“Designing Content URIs” in the “Providing Content” section below. This 
parameter has the same meaning for variants A, B, and C.

projection: This will tell the implementation which columns the 
requester is interested in. Looking at the SQL database type of storing 
data, this lists the column names that should be included in the result. 
There is, however, no strict requirement for a one-to-one mapping.
A requester might ask for a selection parameter X, and the values for X 
might be calculated any way you might possibly think of. If null, return 
all fields. This parameter has the same meaning for variants A, B, and C.

selection: This is only for variants A and B. This specifies a selection 
for the data to be returned. The content provider framework makes no 
assumptions how this selection parameter must look. It is completely 
up to the implementation, and content requesters must yield to what 
the implementation defines. In many cases, you will, however, have 
something like a SQL selection string like name = Jean AND age < 45 
here. If null, return all data sets.



Download 5.42 Mb.

Do'stlaringiz bilan baham:
1   ...   57   58   59   60   61   62   63   64   ...   223




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling