@@ -0,0 +1,2623 @@
+package com.andela.currencycalculator.model.dbparser;%0A%0Aimport android.content.ContentValues;%0Aimport android.content.Context;%0Aimport android.database.Cursor;%0Aimport android.database.sqlite.SQLiteDatabase;%0Aimport android.database.sqlite.SQLiteOpenHelper;%0A%0Aimport com.andela.currencycalculator.model.currency.Currency;%0A%0Aimport java.util.ArrayList;%0A%0A/**%0A * Created by Spykins on 20/02/2016.%0A */%0Apublic class DbHandler extends SQLiteOpenHelper implements DbConfig.FeedEntry%7B%0A%0A%0A    public DbHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) %7B%0A        super(context, DATABASE_NAME, factory, DATABASE_VERSION);%0A    %7D%0A%0A    @Override%0A    public void onCreate(SQLiteDatabase db) %7B%0A        String query = %22CREATE TABLE %22 + TABLE_NAME + %22 (%22+%0A                COLUMN_ID + %22 INTEGER PRIMARY KEY AUTOINCREMENT, %22 +%0A                COLUMN_BASE_CURRENCY + %22 TEXT, %22 +%0A                COLUMN_CURRENCY + %22 TEXT, %22 +%0A                COLUMN_EXCHANGE_RATE + %22 DOUBLE, %22 +%0A                COLUMN_DATE + %22 DATE %22 +%0A                %22);%22;%0A%0A        db.execSQL(query);%0A%0A    %7D%0A%0A    @Override%0A    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) %7B%0A        db.execSQL(%22DROP TABLE IF EXISTS  %22 + TABLE_NAME);%0A        onCreate(db);%0A    %7D%0A%0A    public void insertCurrencyInDatabase(Currency currency)%7B%0A        ContentValues values = new ContentValues();%0A        values.put(COLUMN_BASE_CURRENCY, currency.getBaseCurrency());%0A        values.put(COLUMN_CURRENCY, currency.getCurrency());%0A        values.put(COLUMN_EXCHANGE_RATE, currency.getExchangeRate());%0A        values.put(COLUMN_DATE, currency.getDateCreated());%0A%0A        SQLiteDatabase db = getWritableDatabase();%0A        db.insert(TABLE_NAME, null, values);%0A        db.close();%0A%0A    %7D%0A%0A    public ArrayList%3CCurrency%3E readCurrencyFromDatabase()%7B%0A        ArrayList%3CCurrency%3E allCurrencyInDataBase = new ArrayList%3C%3E();%0A        SQLiteDatabase db = getReadableDatabase();%0A%0A%0A        String query = %22SELECT * FROM %22 + TABLE_NAME;%0A        Cursor cursorHandle = db.rawQuery(query,null);%0A        cursorHandle.moveToFirst();%0A        while (cursorHandle.moveToNext())%7B%0A            String baseCurrency = cursorHandle.getString(cursorHandle.getColumnIndex(COLUMN_BASE_CURRENCY));%0A            String currency = cursorHandle.getString(cursorHandle.getColumnIndex(COLUMN_CURRENCY));%0A            double exchangeRate = cursorHandle.getDouble(cursorHandle.getColumnIndex(COLUMN_EXCHANGE_RATE));%0A            allCurrencyInDataBase.add(new Currency(baseCurrency,exchangeRate,currency));%0A        %7D%0A%0A        db.close();%0A        return allCurrencyInDataBase;%0A    %7D%0A%0A%7D%0A

create DbHandler class for database querying