Pro Android with Kotlin


CHAPTER 6: Content Providers


Download 5.42 Mb.
Pdf ko'rish
bet71/223
Sana04.11.2023
Hajmi5.42 Mb.
#1746807
1   ...   67   68   69   70   71   72   73   74   ...   223
Bog'liq
@de android telegram Pro Android with Kotlin Developing Modern Mobile

75
CHAPTER 6: Content Providers
A Cursor Class Based on the Cursor Interface
A more low-level approach of implementing a cursor is not relying on AbstractCursor but 
instead implementing all the interface methods yourself.
You can then use subclassing as in class MyCursor : Cursor { ... } or use an anonymous 
object as in val myCursor = object : Cursor { ... }. The section “Cursor Interface” in the 
online text companion describes all the interface methods.
Table 6-2. More Cursor Implementations
Name Inside android.database
Description
AbstractWindowedCursor
This inherits from AbstractCursor and owns a CursorWindow 
object holding the data. Subclasses are responsible for filling 
the cursor window with data during their onMove(Int, Int) 
operation, allocating a new cursor window if necessary. It’s 
easier to implement compared to AbstractCursor, but you have 
to add a lot of functionality to onMove().
CrossProcessCursor
This is a cursor implementation that allows using it from 
remote processes. It is just an extension of the android.
database.Cursor interface, containing three more methods: 
fillWindow(Int, CursorWindow), getWindow(): CursorWindow, 
and onMove(Int, Int): Boolean. It does not provide any own 
implementation; you have to overwrite all the methods defined 
in Cursor.
CrossProcessCursorWrapper
This is a cursor implementation that allows using it from remote 
processes. It implements CrossProcessCursor and holds a 
Cursor delegate, which can also be a CrossProcessCursor.
CursorWrapper
This holds a Cursor delegate that all method calls are
forwarded to.
MatrixCursor
This is a full implementation of Cursor, with in-memory storage 
of data as an Object array. You have to use addRow(...) to add 
data. The inner class MatrixCursor.RowBuilder can be used to 
build rows to be used by MatrixCursor.addRow(Array).
MergeCursor
Use this to transparently merge, or concatenate, cursor objects.
sqlite.SQLiteCursor
This is an implementation of Cursor with the data backed by 
a SQLite database. Use one of the constructors to connect the 
cursor with a SQLite database object.



Download 5.42 Mb.

Do'stlaringiz bilan baham:
1   ...   67   68   69   70   71   72   73   74   ...   223




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