0% found this document useful (0 votes)
4 views

Cursors

Cursors in Android represent the result set of a database query, allowing apps to iterate over and access column data. Intents facilitate communication between Android components, enabling the launching of activities, starting services, and delivering broadcasts, with two types: explicit and implicit intents. Explicit intents specify a component to launch, while implicit intents declare a general action, allowing any component to handle it.

Uploaded by

shabeadattil2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Cursors

Cursors in Android represent the result set of a database query, allowing apps to iterate over and access column data. Intents facilitate communication between Android components, enabling the launching of activities, starting services, and delivering broadcasts, with two types: explicit and implicit intents. Explicit intents specify a component to launch, while implicit intents declare a general action, allowing any component to handle it.

Uploaded by

shabeadattil2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Cursors

Cursors contain the result set of a query made against a database in Android. Once a cursor has
been returned from a database query, an app needs to iterate over the result set and read the column
data from the cursor. Internally, the cursor stores the rows of data returned by the query along with
a position that points to the current row of data in the result set. When a cursor is returned from
a query() method, its position points to the spot before the first row of data.

Public cursor cursorFunction()

Cursor
c=sqLiteDatabase.query(Tablename,Tablecolumn,whereclause,whereArgs,groupBy,having,order
By)

Return c

The Cursor class provides the following methods to manipulate its internal position:
• boolean Cursor.move(int offset): Moves the position by the given offset
• boolean Cursor.moveToFirst(): Moves the position to the first row
• boolean Cursor.moveToLast(): Moves the position to the last row
• boolean Cursor.moveToNext(): Moves the cursor to the next row relative to the current
position
• boolean Cursor.moveToPosition(int position): Moves the cursor to the specified position
• Cursor.moveToPrevious(): Moves the cursor to the previous row relative to the current
position

Intent
Android Intent: Intent is giving facilities to communicate between Android components in
several ways. Android Intent is mostly using for launching new Activity from Activity

Uses of Intent in Android

There are three fundamental uses of intents:


1. To start an Activity
An Activity represents a single screen in an app. You can start a new instance of an Activity by
passing an Intent to startActivity(). The Intent describes the activity to start and carries any
necessary data along.
2. To start a Service
A Service is a component that performs operations in the background and does not have a user
interface. You can start a service to perform a one-time operation(such as downloading a file) by
passing an Intent to startService(). The Intent describes which service to start and carries any
necessary data.
To deliver a Broadcast
A broadcast is a message that any app can receive. The system delivers various broadcasts for
system events, such as when the system boots up or the device starts charging. You can deliver a
broadcast to other apps by passing an Intent to sendBroadcast() or sendOrderedBroadcast().

Types of Intents
In Android, there are two types of Intents:

1. Explicit Intents

2. Implicit Intents

Explicit Intents
This intent specifies the component in an app. It is one that we use to launch a specific app component,
such as a particular activity or service in our application. Using this intent we can pass the data from one
activity to another activity.

Create an Explicit Intent


Intent send = new Intent(MainActivity.this, SecondActivity.class);
startActivity(send);

Implicit Intents

Implicit intents do not name a specific component to perform a particular action, but instead it
declares a general action to be performed, which allows any component, even from another app
to handle it. It does not have exact knowledge about the landing component. It can open another
app or its own app’s component and many other options exist.
Examples: Downloaded song, PDF, image, document, dial call, map location, etc.

To create an implicit intent

The constructor of the Implicit Intent's object needs a type of action you want to perform.
An action is a string that specifies the generic action to be performed.

Example

ACTION_VIEW: This action is used when you have some information that an activity can
show to the user, such as a photo to view in a Gallery app
ACTION_SEND: This action is used when you have some data that the user can share through
another app, such as an Email app or some Social Networking app.

Example

Intent intent = new Intent(Intent.ACTION_VIEW);


intent.set Data(Uri.parse("http://www.google.com"));
startActivity(intent);
Android Intent Structure

For Building an Intent there is primary thing have to mention in <intent-filter>

• Action: A string that specifies the generic action to perform, such


as #ACTION_VIEW, #ACTION_EDIT, #ACTION_MAIN, etc.
• Category: Gives additional information about the action to execute. For
example, #CATEGORY_LAUNCHER means it should appear in the Launcher as a top-level
application.
• Data: The data to operate on, such as a personal record in the contacts database,
expressed as a android.net.Uri.
Intent Filter

You might also like