Created
December 11, 2014 20:29
-
-
Save azec-pdx/c46278210e9b311f9996 to your computer and use it in GitHub Desktop.
UI Metode za Content Providere
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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