Back to project page tum-campus.
The source code is released under:
GNU General Public License
If you think the Android project tum-campus listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
?package de.tum.in.tumcampus.models; //from w w w .j a va 2s. c o m import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; /** * Lecture Manager, handles database stuff */ public class LectureManager { /** * Database connection */ private SQLiteDatabase db; /** * Constructor, open/create database, create table if necessary * * <pre> * @param context Context * </pre> */ public LectureManager(Context context) { db = DatabaseManager.getDb(context); // create table if needed db.execSQL("CREATE TABLE IF NOT EXISTS lectures (id VARCHAR PRIMARY KEY, name VARCHAR, module VARCHAR)"); } /** * Get all lectures from the database * * @return Database cursor (name, module, _id) */ public Cursor getAllFromDb() { return db.rawQuery("SELECT name, module, id as _id FROM lectures ORDER BY name", null); } /** * Refresh lectures from the lectures_items table */ public void updateLectures() { db.execSQL("REPLACE INTO lectures (id, name, module) " + "SELECT DISTINCT lectureId, name, module FROM lectures_items"); } /** * Delete a lecture from the database * * <pre> * @param id Lecture ID * </pre> */ public void deleteItemFromDb(String id) { db.execSQL("DELETE FROM lectures WHERE id = ?", new String[] { id }); } }