Selaa lähdekoodia

Initial commit for PersistentDataSQLite project.

Cristian Tanas 11 vuotta sitten
vanhempi
sitoutus
8551e77514

+ 31 - 0
PersistentDataSQLite/AndroidManifest.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.uab.android.persistentdata.sqlite"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <uses-sdk
+        android:minSdkVersion="14"
+        android:targetSdkVersion="19" />
+
+    <application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:name=".CoursesNewFormActivty"
+            android:label="@string/app_name" >
+        </activity>
+        <activity
+            android:name=".CoursesListActivity"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>

BIN
PersistentDataSQLite/ic_launcher-web.png


BIN
PersistentDataSQLite/libs/android-support-v4.jar


BIN
PersistentDataSQLite/res/drawable-hdpi/ic_launcher.png


BIN
PersistentDataSQLite/res/drawable-mdpi/ic_launcher.png


BIN
PersistentDataSQLite/res/drawable-xhdpi/ic_launcher.png


BIN
PersistentDataSQLite/res/drawable-xxhdpi/ic_launcher.png


+ 182 - 0
PersistentDataSQLite/res/layout/activity_main.xml

@@ -0,0 +1,182 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context="${relativePackage}.${activityClass}" >
+    
+    <TextView
+        android:id="@+id/sep1"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_marginTop="5dp"
+        android:text="@string/class_sep"
+        style="?android:attr/listSeparatorTextViewStyle" />
+
+    <TextView
+        android:id="@+id/classLabel"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/sep1"
+        android:layout_alignParentLeft="true"
+        android:layout_marginTop="15dp"
+        android:layout_marginLeft="10dp"
+        android:text="@string/class_name" />
+
+    <AutoCompleteTextView
+        android:id="@+id/classAutoComplete"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/classLabel"
+        android:layout_alignBottom="@+id/classLabel"
+        android:layout_marginLeft="16dp"
+        android:layout_toRightOf="@+id/classLabel"
+        android:ems="10" >
+        
+        <requestFocus />
+ 	</AutoCompleteTextView>
+
+    <TextView
+        android:id="@+id/creditLabel"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignLeft="@+id/classLabel"
+        android:layout_below="@+id/classLabel"
+        android:layout_marginTop="30dp"
+        android:text="@string/credits" />
+
+    <EditText
+        android:id="@+id/creditsEditText"
+        android:layout_width="50dp"
+        android:layout_height="wrap_content"
+        android:layout_alignBottom="@+id/creditLabel"
+        android:layout_toRightOf="@+id/creditLabel"
+        android:layout_marginLeft="16dp"
+        android:ems="10"
+        android:inputType="numberDecimal" >
+    </EditText>
+
+    <TextView
+        android:id="@+id/sep2"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@+id/creditLabel"
+        android:layout_marginTop="25dp"
+        android:text="@string/timetable_sep"
+        style="?android:attr/listSeparatorTextViewStyle" />
+
+    <TextView
+        android:id="@+id/dayOfWeekLabel"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignLeft="@+id/classLabel"
+        android:layout_below="@+id/sep2"
+        android:layout_marginTop="15dp"
+        android:text="@string/day_of_week" />
+
+    <CheckBox
+        android:id="@+id/checkBoxMon"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@+id/dayOfWeekLabel"
+        android:layout_marginTop="10dp"
+        android:text="@string/monday"
+        android:onClick="onCheckBoxClicked" />
+    
+    <CheckBox
+        android:id="@+id/checkBoxTue"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/checkBoxMon"
+        android:layout_alignBottom="@+id/checkBoxMon"
+        android:layout_toRightOf="@+id/checkBoxMon"
+        android:text="@string/tuesday"
+        android:onClick="onCheckBoxClicked" />
+
+    <CheckBox
+        android:id="@+id/checkBoxWed"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/checkBoxTue"
+        android:layout_alignBottom="@+id/checkBoxTue"
+        android:layout_toRightOf="@+id/checkBoxTue"
+        android:text="@string/wednesday"
+        android:onClick="onCheckBoxClicked" />
+
+    <CheckBox
+        android:id="@+id/checkBoxThu"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/checkBoxWed"
+        android:layout_alignBottom="@+id/checkBoxWed"
+        android:layout_toRightOf="@+id/checkBoxWed"
+        android:text="@string/thursday"
+        android:onClick="onCheckBoxClicked" />
+
+    <CheckBox
+        android:id="@+id/checkBoxFri"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/checkBoxThu"
+        android:layout_alignBottom="@+id/checkBoxThu"
+        android:layout_toRightOf="@+id/checkBoxThu"
+        android:text="@string/friday"
+        android:onClick="onCheckBoxClicked" />
+
+    <TextView
+        android:id="@+id/hourLabel"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignLeft="@+id/classLabel"
+        android:layout_below="@+id/checkBoxMon"
+        android:layout_marginTop="20dp"
+        android:text="@string/hour" />
+
+    <TextView
+        android:id="@+id/defaultHourLabel"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/hourLabel"
+        android:layout_alignBottom="@+id/hourLabel"
+        android:layout_toRightOf="@+id/hourLabel"
+        android:layout_marginLeft="15dp"
+        android:text="@string/default_hour_label" />
+
+    <Button
+        android:id="@+id/setHourButton"
+        style="?android:attr/buttonStyleSmall"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/defaultHourLabel"
+        android:layout_alignBottom="@+id/defaultHourLabel"
+        android:layout_toRightOf="@+id/defaultHourLabel"
+        android:layout_marginLeft="10dp"
+        android:text="@string/sethour" />
+
+    <Button
+        android:id="@+id/saveButton"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_alignParentLeft="true"
+        android:text="@string/submit" />
+
+    <Button
+        android:id="@+id/clearButton"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_toRightOf="@+id/saveButton"
+        android:text="@string/clear" />
+
+    <Button
+        android:id="@+id/cancelButton"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_toRightOf="@+id/clearButton"
+        android:text="@string/cancel" />
+
+</RelativeLayout>

+ 21 - 0
PersistentDataSQLite/res/layout/courses_list.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical" >
+    
+    <TextView 
+        android:id="@+id/courseName"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="10dp"
+        android:textSize="24sp"/>
+    
+    <TextView 
+        android:id="@+id/courseCredits"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="10dp"
+        android:textSize="24sp"/>
+
+</LinearLayout>

+ 8 - 0
PersistentDataSQLite/res/layout/list_item.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:padding="5dp" >
+    
+
+</TextView>

+ 9 - 0
PersistentDataSQLite/res/menu/courses_list_menu.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item 
+        android:id="@+id/addNewCourse"
+        android:title="@string/addNewCourseLabel"
+        android:icon="@android:drawable/ic_menu_add"
+        android:showAsAction="ifRoom|withText"/>
+</menu>

+ 11 - 0
PersistentDataSQLite/res/values-v11/styles.xml

@@ -0,0 +1,11 @@
+<resources>
+
+    <!--
+        Base application theme for API 11+. This theme completely replaces
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+        <!-- API 11 theme customizations can go here. -->
+    </style>
+
+</resources>

+ 12 - 0
PersistentDataSQLite/res/values-v14/styles.xml

@@ -0,0 +1,12 @@
+<resources>
+
+    <!--
+        Base application theme for API 14+. This theme completely replaces
+        AppBaseTheme from BOTH res/values/styles.xml and
+        res/values-v11/styles.xml on API 14+ devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+        <!-- API 14 theme customizations can go here. -->
+    </style>
+
+</resources>

+ 12 - 0
PersistentDataSQLite/res/values/arrays.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    
+    <string-array name="classes">
+        <item>Desarrollo de Apps Móviles</item>
+        <item>Desarrollo de Apps en plataforma Android</item>
+        <item>Desarrollo de Apps en plataforma iOS</item>
+        <item>Desarrollo de Apps en plataforma Windows Phone</item>
+        <item>Desarrollo de Apps Multiplataforma</item>
+    </string-array>
+    
+</resources>

+ 25 - 0
PersistentDataSQLite/res/values/strings.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="app_name">PersistentDataSQLite</string>
+    <string name="hello_world">Hello world!</string>
+    <string name="class_name">Nombre asignatura</string>
+    <string name="credits">Créditos</string>
+    <string name="class_sep">Datos asignatura</string>
+    <string name="timetable_sep">Horario</string>
+    <string name="day_of_week">Día de la semana</string>
+    <string name="monday">Lun</string>
+    <string name="tuesday">Mar</string>
+    <string name="wednesday">Mie</string>
+    <string name="thursday">Jue</string>
+    <string name="friday">Vie</string>
+    <string name="hour">Hora:</string>
+    <string name="default_hour_label">00:00</string>
+    <string name="sethour">Establecer</string>
+    <string name="submit">Guardar</string>
+    <string name="clear">Limpiar</string>
+    <string name="cancel">Cancelar</string>
+    <string name="title_activity_courses_list">Lista asignaturas</string>
+    <string name="addNewCourseLabel">Nueva asignatura</string>
+
+</resources>

+ 20 - 0
PersistentDataSQLite/res/values/styles.xml

@@ -0,0 +1,20 @@
+<resources>
+
+    <!--
+        Base application theme, dependent on API level. This theme is replaced
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Light">
+        <!--
+            Theme customizations available in newer API levels can go in
+            res/values-vXX/styles.xml, while customizations related to
+            backward-compatibility can go here.
+        -->
+    </style>
+
+    <!-- Application theme. -->
+    <style name="AppTheme" parent="AppBaseTheme">
+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+    </style>
+
+</resources>

+ 70 - 0
PersistentDataSQLite/src/org/uab/android/persistentdata/sqlite/CoursesListActivity.java

@@ -0,0 +1,70 @@
+package org.uab.android.persistentdata.sqlite;
+
+import android.app.ListActivity;
+import android.content.Intent;
+import android.database.Cursor;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.widget.SimpleCursorAdapter;
+
+public class CoursesListActivity extends ListActivity {
+	
+	private static final int		COURSE_NEW_REQUEST_CODE = 1;
+	
+	SimpleCursorAdapter		coursesListAdapter;
+	SQLiteDataRepository 	sqliteDatabase;
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		
+		sqliteDatabase = new SQLiteDataRepository(this);
+		Cursor allCourses = sqliteDatabase.fetchAllCourses();
+		
+		coursesListAdapter = new SimpleCursorAdapter(
+				this, 
+				R.layout.courses_list, 
+				allCourses, 
+				new String[] { DatabaseOpenHelper.COURSE_NAME, DatabaseOpenHelper.COURSE_NUM_OF_CREDITS }, 
+				new int[] { R.id.courseName, R.id.courseCredits }, 
+				0);
+		
+		setListAdapter(coursesListAdapter);
+	}
+	
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu) {
+		
+		MenuInflater inflater = getMenuInflater();
+		inflater.inflate(R.menu.courses_list_menu, menu);
+		return super.onCreateOptionsMenu(menu);
+	}
+	
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item) {
+		
+		switch ( item.getItemId() ) {
+		case R.id.addNewCourse:
+			Intent addNewCourseIntent = new Intent(this, CoursesNewFormActivty.class);
+			startActivityForResult(addNewCourseIntent, COURSE_NEW_REQUEST_CODE);
+			return true;
+
+		default:
+			return super.onOptionsItemSelected(item);
+		}
+		
+	}
+	
+	@Override
+	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+		
+		if ( resultCode == RESULT_OK && requestCode == COURSE_NEW_REQUEST_CODE ) {
+			
+			Cursor allCourses = sqliteDatabase.fetchAllCourses();
+			coursesListAdapter.changeCursor(allCourses);
+			coursesListAdapter.notifyDataSetChanged();
+		}
+	}
+}

+ 133 - 0
PersistentDataSQLite/src/org/uab/android/persistentdata/sqlite/CoursesNewFormActivty.java

@@ -0,0 +1,133 @@
+package org.uab.android.persistentdata.sqlite;
+
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Map;
+
+import android.app.Activity;
+import android.app.TimePickerDialog;
+import android.app.TimePickerDialog.OnTimeSetListener;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.AutoCompleteTextView;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.TimePicker;
+
+public class CoursesNewFormActivty extends Activity {
+	
+	private static final String 		LOG_TAG = "PERSISTENT_DATA_SQLITE_COURSE_NEW_FORM_ACTIVITY";
+	
+	AutoCompleteTextView	classesAutoCompleteTextView;
+	EditText				numberOfCreditsEditText;
+	TextView				defaultHourTextView;
+	Button					setHourButton;
+	
+	Button					saveButton;
+	
+	Map<Integer, Boolean> checkBoxStateMap = new HashMap<>();
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_main);
+		
+		// Get a reference to the UI element
+		classesAutoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.classAutoComplete);
+		
+		numberOfCreditsEditText = (EditText) findViewById(R.id.creditsEditText);
+		
+		// Set an ArrayAdapter containing pre-define classes names
+		ArrayAdapter<CharSequence> classesAdapter = ArrayAdapter.
+				createFromResource(this, R.array.classes, R.layout.list_item);
+		classesAutoCompleteTextView.setAdapter(classesAdapter);
+		
+		setHourButton = (Button) findViewById(R.id.setHourButton);
+		
+		// Set an OnClickListener for the set hour Button
+		setHourButton.setOnClickListener(new OnClickListener() {
+			
+			@Override
+			public void onClick(View arg0) {
+				
+				// Get an instance of a Calendar to set the current time
+				Calendar c = Calendar.getInstance();
+				int hourOfDay = c.get(Calendar.HOUR_OF_DAY);
+				int minute = c.get(Calendar.MINUTE);
+				
+				// Create a new dialog that displays a TimePicker
+				TimePickerDialog timePickerDialog = new TimePickerDialog(
+						CoursesNewFormActivty.this, 
+						timeSetListener, 
+						hourOfDay, 
+						minute, 
+						true);
+				timePickerDialog.show();
+			}
+		});
+		
+		defaultHourTextView = (TextView) findViewById(R.id.defaultHourLabel);
+		
+		saveButton = (Button) findViewById(R.id.saveButton);
+		saveButton.setOnClickListener(new OnClickListener() {
+			
+			@Override
+			public void onClick(View v) {
+				
+				String courseName = classesAutoCompleteTextView.getText().toString();
+				int numberOfCredits = Integer.parseInt(numberOfCreditsEditText.getText().toString());
+				String checkBoxState = checkBoxStateMap.keySet().toString();
+				String hour = defaultHourTextView.getText().toString();
+				
+				SQLiteDataRepository sqliteDatabase = new SQLiteDataRepository(CoursesNewFormActivty.this);
+				sqliteDatabase.saveCourse(courseName, numberOfCredits, checkBoxState, hour);
+				
+				Log.i(LOG_TAG, "Saved " + 
+						courseName + " " + numberOfCredits + " " + checkBoxState + " "+ hour + 
+						" to database.");
+				
+				clearForm();
+				setResult(RESULT_OK);
+				finish();
+			}
+		});
+	}
+	
+	private void clearForm() {
+		
+		classesAutoCompleteTextView.setText("");
+		numberOfCreditsEditText.setText("");
+		
+		for ( int checkBoxId : checkBoxStateMap.keySet() ) {
+			
+			CheckBox cb = (CheckBox) findViewById(checkBoxId);
+			cb.setChecked(false);
+		}
+		
+		defaultHourTextView.setText(R.string.default_hour_label);
+	}
+	
+	public void onCheckBoxClicked(View v) {
+		
+		CheckBox cb = (CheckBox) v;
+		checkBoxStateMap.put(cb.getId(), cb.isChecked());
+		
+	}
+	
+	// Implementation of the OnTimeSetListener interface
+	OnTimeSetListener timeSetListener = new OnTimeSetListener() {
+		
+		// This method is called when the user click done on the TimePicker
+		@Override
+		public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
+			
+			// Set the hour and minute on the corresponding TextView
+			defaultHourTextView.setText(hourOfDay + ":" + minute);
+		}
+	};
+}

+ 51 - 0
PersistentDataSQLite/src/org/uab/android/persistentdata/sqlite/DatabaseOpenHelper.java

@@ -0,0 +1,51 @@
+package org.uab.android.persistentdata.sqlite;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+
+public class DatabaseOpenHelper extends SQLiteOpenHelper {
+	
+	private static final String		DATABASE_NAME = "courses";
+	private static final int		DATABASE_VERSION = 1;
+	
+	static final String		COURSES_TABLE_NAME = "ASIGNATURAS";
+	static final String		_ID = "_id";
+	static final String		COURSE_NAME = "asignatura";
+	static final String		COURSE_NUM_OF_CREDITS = "creditos";
+	static final String		COURSE_DAYS_OF_WEEK = "dias";
+	static final String		COURSE_STARTS_AT = "hora";
+	
+	static final String[] COLUMNS = {
+		_ID,
+		COURSE_NAME,
+		COURSE_NUM_OF_CREDITS,
+		COURSE_DAYS_OF_WEEK,
+		COURSE_STARTS_AT
+	};
+	
+	private static final String CREATE_COURSES_TABLE = 
+			"CREATE TABLE " + COURSES_TABLE_NAME + "( " +
+					_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
+					COURSE_NAME + " TEXT NOT NULL, " +
+					COURSE_NUM_OF_CREDITS + " INTEGER NOT NULL, " +
+					COURSE_DAYS_OF_WEEK + " TEXT, " +
+					COURSE_STARTS_AT + " TEXT)";
+	
+	public DatabaseOpenHelper(Context context) {
+		super(context, DATABASE_NAME, null, DATABASE_VERSION);
+	}
+
+	@Override
+	public void onCreate(SQLiteDatabase db) {
+		
+		db.execSQL(CREATE_COURSES_TABLE);
+	}
+
+	@Override
+	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+		// TODO Auto-generated method stub
+
+	}
+
+}

+ 61 - 0
PersistentDataSQLite/src/org/uab/android/persistentdata/sqlite/SQLiteDataRepository.java

@@ -0,0 +1,61 @@
+package org.uab.android.persistentdata.sqlite;
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+
+public class SQLiteDataRepository {
+	
+	private DatabaseOpenHelper		databaseOpenHelper;
+
+	public SQLiteDataRepository(Context context) {
+		
+		this.databaseOpenHelper = new DatabaseOpenHelper(context);
+	}
+	
+	public void saveCourse(String courseName, int numberOfCredits, 
+			String checkBoxState, String hour) {
+		
+		ContentValues values = new ContentValues();
+		values.put(DatabaseOpenHelper.COURSE_NAME, courseName);
+		values.put(DatabaseOpenHelper.COURSE_NUM_OF_CREDITS, numberOfCredits);
+		values.put(DatabaseOpenHelper.COURSE_DAYS_OF_WEEK, checkBoxState);
+		values.put(DatabaseOpenHelper.COURSE_STARTS_AT, hour);
+		
+		this.databaseOpenHelper.getWritableDatabase().insert(
+				DatabaseOpenHelper.COURSES_TABLE_NAME, 
+				null, 
+				values);
+	}
+	
+	public Cursor fetchCourseById(int courseId) {
+		
+		String selection = DatabaseOpenHelper._ID + " = ?";
+		String[] selectionArgs = new String[] { String.valueOf(courseId) };
+		
+		Cursor result = this.databaseOpenHelper.getReadableDatabase()
+				.query(
+						DatabaseOpenHelper.COURSES_TABLE_NAME, 
+						DatabaseOpenHelper.COLUMNS, 
+						selection, 
+						selectionArgs, 
+						null, 
+						null, 
+						null);
+		return result;
+	}
+	
+	public Cursor fetchAllCourses() {
+		
+		Cursor result = this.databaseOpenHelper.getReadableDatabase()
+				.query(
+						DatabaseOpenHelper.COURSES_TABLE_NAME, 
+						DatabaseOpenHelper.COLUMNS, 
+						null, 
+						null, 
+						null, 
+						null, 
+						null);
+		return result;
+	}
+}