Skip to content

Instantly share code, notes, and snippets.

@azec-pdx
Created December 11, 2014 20:29
Show Gist options
  • Save azec-pdx/c46278210e9b311f9996 to your computer and use it in GitHub Desktop.
Save azec-pdx/c46278210e9b311f9996 to your computer and use it in GitHub Desktop.
UI Metode za Content Providere
public void onClickRetrieveStudents(View view) {
//Retrueve student records
String URL = "content://ba.edu.eksa.Fakultet/studenti";
Uri students = Uri.parse(URL);
String[] projection =
{
StudentProvider._ID,
StudentProvider.NAME,
StudentProvider.GRADE
};
String sortOrder = StudentProvider.NAME;
Cursor c = getApplicationContext().getContentResolver().query(students, projection, null, null, sortOrder);
if (c.moveToFirst()) {
do {
Toast.makeText(this,
c.getString(c.getColumnIndex(StudentProvider._ID)) +
", " + c.getString(c.getColumnIndex(StudentProvider.NAME)) +
", " + c.getString(c.getColumnIndex(StudentProvider.GRADE)),
Toast.LENGTH_SHORT).show();
} while (c.moveToNext());
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment