--- /dev/null
+/* ownCloud Android client application\r
+ * Copyright (C) 2011 Bartek Przybylski\r
+ *\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+ *\r
+ */\r
+package com.owncloud.android.db;\r
+\r
+import java.util.Vector;\r
+\r
+import com.owncloud.android.OwnCloudSession;\r
+\r
+\r
+import android.content.ContentValues;\r
+import android.content.Context;\r
+import android.database.Cursor;\r
+import android.database.sqlite.SQLiteDatabase;\r
+import android.database.sqlite.SQLiteOpenHelper;\r
+\r
+/**\r
+ * Custom database helper for ownCloud\r
+ * \r
+ * @author Bartek Przybylski\r
+ * \r
+ */\r
+public class DbHandler {\r
+ private SQLiteDatabase mDB;\r
+ private OpenerHepler mHelper;\r
+ private final String mDatabaseName = "ownCloud";\r
+ private final String TABLE_SESSIONS = "sessions";\r
+ private final int mDatabaseVersion = 1;\r
+ \r
+ private final String TABLE_INSTANT_UPLOAD = "instant_upload";\r
+\r
+ public DbHandler(Context context) {\r
+ mHelper = new OpenerHepler(context);\r
+ mDB = mHelper.getWritableDatabase();\r
+ }\r
+\r
+ public void close() {\r
+ mDB.close();\r
+ }\r
+\r
+ public boolean putFileForLater(String filepath, String account) {\r
+ ContentValues cv = new ContentValues();\r
+ cv.put("path", filepath);\r
+ cv.put("account", account);\r
+ return mDB.insert(TABLE_INSTANT_UPLOAD, null, cv) != -1;\r
+ }\r
+ \r
+ public Cursor getAwaitingFiles() {\r
+ return mDB.query(TABLE_INSTANT_UPLOAD, null, null, null, null, null, null);\r
+ }\r
+ \r
+ public void clearFiles() {\r
+ mDB.delete(TABLE_INSTANT_UPLOAD, null, null);\r
+ }\r
+ \r
+ private class OpenerHepler extends SQLiteOpenHelper {\r
+ public OpenerHepler(Context context) {\r
+ super(context, mDatabaseName, null, mDatabaseVersion);\r
+ }\r
+\r
+ @Override\r
+ public void onCreate(SQLiteDatabase db) {\r
+ db.execSQL("CREATE TABLE " + TABLE_INSTANT_UPLOAD + " ("\r
+ + " _id INTEGET PRIMARY KEY, "\r
+ + " path TEXT,"\r
+ + " account TEXT);");\r
+ }\r
+\r
+ @Override\r
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {\r
+ }\r
+ }\r
+}\r