Guest User

Untitled

a guest
Jul 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. public class populatingLectures extends ListActivity{
  2.  
  3. private static String[] FROM = {SUBJECT, TOPIC, LECTURENUMBER, DATE };
  4. private static int[] TO = {R.id.subject, R.id.topic,
  5. R.id.lecturenumber, R.id.date };
  6. private static String[] data = { SUBJECT, TOPIC, LECTURENUMBER, _DATA };
  7. private static String ORDER_BY = DATE + " DESC";
  8. private SoftCopyDatabase lectures;
  9. String gotId;
  10.  
  11.  
  12. @Override
  13. public void onCreate(Bundle savedInstanceState) {
  14. super.onCreate(savedInstanceState);
  15. SoftCopyDatabase lectures = new SoftCopyDatabase(this);
  16. try {
  17. Cursor cursor = getLectures();
  18. showLectures(cursor);
  19. } finally {
  20. lectures.close();
  21. }
  22. }
  23.  
  24. public void onStart() {
  25. super.onStart();
  26. lectures = new SoftCopyDatabase(this);
  27. try {
  28. Cursor cursor = getLectures();
  29. showLectures(cursor);
  30. } finally {
  31. lectures.close();
  32. }
  33. }
  34.  
  35. private Cursor getLectures() {
  36.  
  37. SQLiteDatabase db = lectures.getReadableDatabase();
  38.  
  39. Cursor cursor = db.query(TABLE_NAME,null, "subject=?", new String[] {OpenClick.subjectName}, null, null,
  40. ORDER_BY);
  41. startManagingCursor(cursor);
  42. return cursor;
  43. }
  44.  
  45.  
  46. private void showLectures(Cursor cursor) {
  47.  
  48. SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
  49. R.layout.item_lectures, cursor, FROM, TO);
  50. setListAdapter(adapter);
  51. }
  52.  
  53. private Cursor getFileName(String ID) {
  54.  
  55. SQLiteDatabase db = lectures.getReadableDatabase();
  56. Cursor cursor = db.query(TABLE_NAME, data, "_ID=?",
  57. new String[] { ID }, null, null, null);
  58. startManagingCursor(cursor);
  59. return cursor;
  60. }
  61.  
  62.  
  63. @Override
  64. protected void onListItemClick(ListView listView, View view, int position,
  65. long id) {
  66. super.onListItemClick(listView, view, position, id);
  67.  
  68. //...CODE TO START NEW ACTIVITY
  69.  
  70. }
  71. }
  72.  
  73.  
  74. }
  75.  
  76. finally {
  77. lectures.close();
  78. }
  79.  
  80. lectures.close()
Add Comment
Please, Sign In to add comment