// Path: app/src/main/java/com/mschlauch/comfortreader/DatabaseHelper.java
// public class DatabaseHelper extends SQLiteOpenHelper {
// 
//     // Table Name
//     public static final String TABLE_NAME = "COUNTRIES";
// 
//     // Table columns
//     public static final String _ID = "_id";
//     public static final String BOOKPATH = "bookpath";
//     public static final String BOOKTEXT = "booktext";
//     public static final String BOOKLENGTH = "booklength";//int
//     public static final String BOOKPOSITION = "bookposition";//int
//     public static final String BOOKWPM = "bookwpm";//int speed configuration
//     public static final String BOOKLASTREADING = "readingtimestamp";
// 
// 
// 
//     // Database Information
//     static final String DB_NAME = "JOURNALDEV_COUNTRIES.DB";
// 
//     // database version
//     static final int DB_VERSION = 1;
// 
//     // Creating table query
//     private static final String CREATE_TABLE = "create table " + TABLE_NAME + "(" + _ID
//             + " INTEGER PRIMARY KEY AUTOINCREMENT, " + BOOKPATH + " TEXT NOT NULL, "
//             + BOOKTEXT + " TEXT," + BOOKLENGTH + " INTEGER," + BOOKPOSITION
//             + " INTEGER," + BOOKWPM + " INTEGER," + BOOKLASTREADING + " INTEGER" +  ");";
// 
//     public DatabaseHelper(Context context) {
//         super(context, DB_NAME, null, DB_VERSION);
//     }
// 
//     @Override
//     public void onCreate(SQLiteDatabase db) {
//         db.execSQL(CREATE_TABLE);
//     }
// 
//     @Override
//     public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
//         db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
//         onCreate(db);
//     }
// }


import com.mschlauch.comfortreader.DatabaseHelper;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import java.sql.Timestamp;
    }

    public Cursor fetch() {
        String[] columns = new String[] { DatabaseHelper._ID, DatabaseHelper.BOOKPATH, DatabaseHelper.BOOKTEXT, DatabaseHelper.BOOKLENGTH, DatabaseHelper.BOOKPOSITION,  DatabaseHelper.BOOKWPM};

        Cursor cursor = database.query(DatabaseHelper.TABLE_NAME, columns, null, null, null, null, null);
        if (cursor != null) {
            cursor.moveToFirst();
        }
        return cursor;
    }

    public Cursor fetchwithBookpath(String bookpathselected) {
        String[] columns = new String[] { DatabaseHelper._ID, DatabaseHelper.BOOKPATH, DatabaseHelper.BOOKTEXT, DatabaseHelper.BOOKLENGTH, DatabaseHelper.BOOKPOSITION,  DatabaseHelper.BOOKWPM};
        String whereClause = DatabaseHelper.BOOKPATH+"=?";
        String[] whereArgs = new String[] {
                "" + bookpathselected,
        };
        Cursor cursor = database.query(DatabaseHelper.TABLE_NAME, columns, whereClause, whereArgs, null, null, null);
        if (cursor != null) {
            cursor.moveToFirst();
        }
        return cursor;
    }
    public Cursor fetchwithBookID (int bookid) {
        String[] columns = new String[] { DatabaseHelper._ID, DatabaseHelper.BOOKPATH, DatabaseHelper.BOOKTEXT, DatabaseHelper.BOOKLENGTH, DatabaseHelper.BOOKPOSITION,  DatabaseHelper.BOOKWPM};
        String whereClause = DatabaseHelper._ID +"=?";
        String[] whereArgs = new String[] {
                "" + bookid,
        };
// Path: app/src/main/java/com/mschlauch/comfortreader/DatabaseHelper.java
// public class DatabaseHelper extends SQLiteOpenHelper {
// 
//     // Table Name
//     public static final String TABLE_NAME = "COUNTRIES";
// 
//     // Table columns
//     public static final String _ID = "_id";
//     public static final String BOOKPATH = "bookpath";
//     public static final String BOOKTEXT = "booktext";
//     public static final String BOOKLENGTH = "booklength";//int
//     public static final String BOOKPOSITION = "bookposition";//int
//     public static final String BOOKWPM = "bookwpm";//int speed configuration
//     public static final String BOOKLASTREADING = "readingtimestamp";
// 
// 
// 
//     // Database Information
//     static final String DB_NAME = "JOURNALDEV_COUNTRIES.DB";
// 
//     // database version
//     static final int DB_VERSION = 1;
// 
//     // Creating table query
//     private static final String CREATE_TABLE = "create table " + TABLE_NAME + "(" + _ID
//             + " INTEGER PRIMARY KEY AUTOINCREMENT, " + BOOKPATH + " TEXT NOT NULL, "
//             + BOOKTEXT + " TEXT," + BOOKLENGTH + " INTEGER," + BOOKPOSITION
//             + " INTEGER," + BOOKWPM + " INTEGER," + BOOKLASTREADING + " INTEGER" +  ");";
// 
//     public DatabaseHelper(Context context) {
//         super(context, DB_NAME, null, DB_VERSION);
//     }
// 
//     @Override
//     public void onCreate(SQLiteDatabase db) {
//         db.execSQL(CREATE_TABLE);
//     }
// 
//     @Override
//     public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
//         db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
//         onCreate(db);
//     }
// }


// Path: app/src/main/java/com/mschlauch/comfortreader/DBManager.java
import com.mschlauch.comfortreader.DatabaseHelper;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import java.sql.Timestamp;

    }

    public Cursor fetch() {
        String[] columns = new String[] { DatabaseHelper._ID, DatabaseHelper.BOOKPATH, DatabaseHelper.BOOKTEXT, DatabaseHelper.BOOKLENGTH, DatabaseHelper.BOOKPOSITION,  DatabaseHelper.BOOKWPM};

        Cursor cursor = database.query(DatabaseHelper.TABLE_NAME, columns, null, null, null, null, null);
        if (cursor != null) {
            cursor.moveToFirst();
        }
        return cursor;
    }

    public Cursor fetchwithBookpath(String bookpathselected) {
        String[] columns = new String[] { DatabaseHelper._ID, DatabaseHelper.BOOKPATH, DatabaseHelper.BOOKTEXT, DatabaseHelper.BOOKLENGTH, DatabaseHelper.BOOKPOSITION,  DatabaseHelper.BOOKWPM};
        String whereClause = DatabaseHelper.BOOKPATH+"=?";
        String[] whereArgs = new String[] {
                "" + bookpathselected,
        };
        Cursor cursor = database.query(DatabaseHelper.TABLE_NAME, columns, whereClause, whereArgs, null, null, null);
        if (cursor != null) {
            cursor.moveToFirst();
        }
        return cursor;
    }
    public Cursor fetchwithBookID (int bookid) {
        String[] columns = new String[] { DatabaseHelper._ID, DatabaseHelper.BOOKPATH, DatabaseHelper.BOOKTEXT, DatabaseHelper.BOOKLENGTH, DatabaseHelper.BOOKPOSITION,  DatabaseHelper.BOOKWPM};
        String whereClause = DatabaseHelper._ID +"=?";
        String[] whereArgs = new String[] {
                "" + bookid,
        };
        Cursor cursor = database.query(DatabaseHelper.TABLE_NAME, columns, whereClause, whereArgs, null, null, null);