Guest User

Untitled

a guest
Oct 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. private static final String CREATE_TABLE_STUDENT_LESSON = " create table STUDENTSPECIFICLESSON ( _id TEXT , _viewID INTEGER PRIMARY KEY AUTOINCREMENT , _LESSON_TITLE TEXT , _LESSON_DATE TEXT , _LESSON_PROBLEM TEXT );";
  2.  
  3. public void onCreate(SQLiteDatabase db) {
  4. db.execSQL(CREATE_TABLE_STUDENT_LESSON);
  5. }
  6.  
  7. public void insertLesson(String _id, String lessonTitle, String lessonDate, String lessonProblem) {
  8. ContentValues contentValue = new ContentValues();
  9. contentValue.put(SQLiteHelper._ID, _id);
  10. contentValue.put(SQLiteHelper.LESSON_TITLE, lessonTitle);
  11. contentValue.put(SQLiteHelper.LESSON_DATE, lessonDate);
  12. contentValue.put(SQLiteHelper.LESSON_PROBLEM, lessonProblem);
  13. this.getWritableDatabase().insert(SQLiteHelper.TABLE_NAME_STUDENTSPECIFICLESSON, null, contentValue);
  14. }
  15.  
  16. sqLiteHelper.insertLesson(id,etLessonTitle.getText().toString(),currentDateandTime,etLessonProbStu.getText().toString());
  17.  
  18. public String getLessonViewHolderID(String _path){
  19. String id = null;
  20.  
  21. Cursor cursor = getReadableDatabase().rawQuery("Select "+SQLiteHelper._viewID+" from "+SQLiteHelper.TABLE_NAME_STUDENTSPECIFICLESSON+" Where "
  22. +SQLiteHelper.LESSON_TITLE +"='"+_path+"'",null);
  23.  
  24. if (cursor != null) {
  25. cursor.moveToFirst();
  26. }
  27. if (cursor == null) {
  28. } else if (cursor.moveToFirst()) {
  29. do {
  30. id = String.valueOf(cursor.getInt(cursor.getColumnIndex(SQLiteHelper._viewID)));
  31.  
  32. } while (cursor.moveToNext());
  33. cursor.close();
  34. } else {
  35.  
  36. }
  37. return id;
  38. }
  39.  
  40. public String getLessonProblem(String _id){
  41.  
  42.  
  43. String id = null;
  44.  
  45. Cursor cursor = getReadableDatabase().rawQuery("Select _LESSON_PROBLEM from "+SQLiteHelper.TABLE_NAME_STUDENTSPECIFICLESSON+" Where "
  46. +SQLiteHelper._viewID +"='"+_id+"'",null);
  47.  
  48.  
  49. if (cursor != null) {
  50. cursor.moveToFirst();
  51. }
  52. if (cursor == null) {
  53. } else if (cursor.moveToFirst()) {
  54. do {
  55. id = String.valueOf(cursor.getInt(cursor.getColumnIndex("_LESSON_PROBLEM")));
  56.  
  57. } while (cursor.moveToNext());
  58. cursor.close();
  59. } else {
  60.  
  61. }
  62. return id;
  63.  
  64. }
  65.  
  66. String lessonProblem = helper.getLessonProblem(viewId);
Add Comment
Please, Sign In to add comment