Skip to content

Instantly share code, notes, and snippets.

View sahalsajjad's full-sized avatar

Sahal Sajjad sahalsajjad

View GitHub Profile
@jonikarppinen
jonikarppinen / ContactsFragment.java
Last active February 23, 2020 09:43
Fixes to "Retrieving a List of Contacts" Android tutorial by Google: https://developer.android.com/training/contacts-provider/retrieve-names.html
// Fixes to compilation errors in "Define the onItemClick() method" section
// Doesn't compile
Cursor cursor = parent.getAdapter().getCursor();
// Fixed (not sure if this is the cleanest way though)
Cursor cursor = ((SimpleCursorAdapter) parent.getAdapter()).getCursor();
// Doesn't compile
mContactId = getLong(CONTACT_ID_INDEX);
// Fixed