1 /* ownCloud Android client application 
   2  *   Copyright (C) 2011  Bartek Przybylski 
   4  *   This program is free software: you can redistribute it and/or modify 
   5  *   it under the terms of the GNU General Public License as published by 
   6  *   the Free Software Foundation, either version 3 of the License, or 
   7  *   (at your option) any later version. 
   9  *   This program is distributed in the hope that it will be useful, 
  10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of 
  11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  12  *   GNU General Public License for more details. 
  14  *   You should have received a copy of the GNU General Public License 
  15  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. 
  18 package eu
.alefzero
.owncloud
.db
; 
  20 import java
.util
.Vector
; 
  22 import eu
.alefzero
.owncloud
.OwnCloudSession
; 
  24 import android
.content
.ContentValues
; 
  25 import android
.content
.Context
; 
  26 import android
.database
.Cursor
; 
  27 import android
.database
.sqlite
.SQLiteDatabase
; 
  28 import android
.database
.sqlite
.SQLiteOpenHelper
; 
  31  * Custom database helper for ownCloud 
  33  * @author Bartek Przybylski 
  36 public class DbHandler 
{ 
  37     private SQLiteDatabase mDB
; 
  38     private OpenerHepler mHelper
; 
  39     private final String mDatabaseName 
= "ownCloud"; 
  40     private final String TABLE_SESSIONS 
= "sessions"; 
  41     private final int mDatabaseVersion 
= 1; 
  43     private final String TABLE_INSTANT_UPLOAD 
= "instant_upload"; 
  45     public DbHandler(Context context
) { 
  46         mHelper 
= new OpenerHepler(context
); 
  47         mDB 
= mHelper
.getWritableDatabase(); 
  54     public boolean putFileForLater(String filepath
, String account
) { 
  55         ContentValues cv 
= new ContentValues(); 
  56         cv
.put("path", filepath
); 
  57         cv
.put("account", account
); 
  58         return mDB
.insert(TABLE_INSTANT_UPLOAD
, null
, cv
) != -1; 
  61     public Cursor 
getAwaitingFiles() { 
  62         return mDB
.query(TABLE_INSTANT_UPLOAD
, null
, null
, null
, null
, null
, null
); 
  65     public void clearFiles() { 
  66         mDB
.delete(TABLE_INSTANT_UPLOAD
, null
, null
); 
  69     private class OpenerHepler 
extends SQLiteOpenHelper 
{ 
  70         public OpenerHepler(Context context
) { 
  71             super(context
, mDatabaseName
, null
, mDatabaseVersion
); 
  75         public void onCreate(SQLiteDatabase db
) { 
  76             db
.execSQL("CREATE TABLE " + TABLE_INSTANT_UPLOAD 
+ " (" 
  77                         + " _id INTEGET PRIMARY KEY, " 
  83         public void onUpgrade(SQLiteDatabase db
, int oldVersion
, int newVersion
) {