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; // w w w .ja v a 2 s .c o m import java.io.File; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import de.tum.in.tumcampus.common.Const; /** * Database singleton */ abstract public class DatabaseManager { /** * Database connection */ private static SQLiteDatabase db; /** * Constructor, open/create database, create table if necessary * * <pre> * @param c Context * @return SQLiteDatabase Db * </pre> */ public static SQLiteDatabase getDb(Context c) { if (db == null) { File f = c.getDatabasePath(Const.db); f.getParentFile().mkdirs(); db = SQLiteDatabase.openDatabase(c.getDatabasePath(Const.db).toString(), null, SQLiteDatabase.CREATE_IF_NECESSARY); } return db; } }