UNIT 3 MOB
UNIT 3 MOB
<DatePicker
android:id="@+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:datePickerMode="calendar"
/>
public void onDateChanged(DatePicker view, int year, int month, int day) {
String msg = "You Selected: " + day + "/" + (month + 1) + "/" + year;
Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();
}
}
);
}
}
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SELECT DATE"
android:id="@+id/btn_date"/>
<TimePicker
android:id="@+id/timePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:timePickerMode="spinner" />
<ImageView
android:id="@+id/img"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/lion" />
ImageView i = findViewById(R.id.img);
i.setImageResource(R.drawable.lion);
<resources>
<style name="GreenText" parent="TextAppearance.AppCompat">
<item name="android:textColor">#00FF00</item>
</style>
</resources>
<TextView
style="@style/GreenText"
... />
<resources>
<color name="colorPrimary">#00cccc</color>
<color name="colorPrimaryDark">#006666</color>
<color name="colorIt">#188596</color>
<color name="colorAccent">#BBF1F1</color>
<color name="colorAccent1">#1397B1</color>
</resources>
Apoorva S., Asst. Prof., Dept of CS www.iadc.ac.in
<style name="TextviewStyle" parent="@android:style/Widget.TextView">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">0dp</item>
<item name="android:layout_marginTop">10dp</item> <resources>
<item name="android:textColor">#86AD33</item> <color name="colorPrimary">#00cccc</color>
<item name="android:textStyle">bold</item>
<color name="colorPrimaryDark">#006666</color>
<item name="android:textSize">20dp</item>
<color name="colorIt">#188596</color>
</style>
<color name="colorAccent">#BBF1F1</color>
<style name="ButtonStyle" parent="@android:style/Widget.Button">
<item name="android:layout_width">wrap_content</item> <color name="colorAccent1">#1397B1</color>
<item name="android:layout_height">wrap_content</item> </resources>
<item name="android:layout_marginLeft">20dp</item>
<item name="android:layout_marginTop">10dp</item>
<item name="android:textColor">@color/colorIt</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">30dp</item>
</style>
onCreate() When the receiver is formed, this function in Android initializes the
Provider.
query() In Android, it receives a query request from the user and responds with a
cursor.
insert() We use this method to insert data into our content provider.
update() This function updates existing data in a row and returns the updated row
data.
delete() Removes existing data from the content provider.
getType() This function returns the Multipurpose Internet Mail Extension data type
to the supplied Content URI.
MediaStore: This built-in content provider is used to provide access to the device's
media files such as videos, photos, and also audio recordings.
UserDictionary: Provides access to the user dictionary data (stores custom words
that can be used by the keyboard app for suggestions).
SQLite: It's a database engine for Android that provides a lightweight and efficient way to store and
retrieve data.
Google Drive: Google Drive is a cloud-based file storage and sharing service that provides access to
files from anywhere and on any device.
Twitter API: Twitter API provides access to Twitter data, such as tweets, mentions, and direct
messages.
Other examples of popular third-party content providers are Dropbox, Microsoft OneDrive, and
Amazon S3.
Apoorva S., Asst. Prof., Dept of CS www.iadc.ac.in
Accessing Data with Content Provider
It involves
determining the Content URI,
obtaining a ContentResolver instance, and then
using the appropriate CRUD operations to manipulate the data.
ON Activity Creation:
SET layout to activity_main
FIND ListView by ID and assign to listViewContacts
FIND Button by ID
ON Button Click:
CALL checkContactsPermission()
FUNCTION checkContactsPermission():
IF permission to READ_CONTACTS is NOT granted:
REQUEST permission from user
ELSE:
CALL loadContacts()
FUNCTION loadContacts():
CREATE empty list called contacts
END MainActivity