@@ -0,0 +1,2326 @@
+package pl.vehicle_history.database;%0A%0Aimport static pl.vehicle_history.database.DbConstants.COLUMN_LABEL;%0Aimport static pl.vehicle_history.database.DbConstants.COLUMN_REGISTRATION_DATE;%0Aimport static pl.vehicle_history.database.DbConstants.COLUMN_REGISTRATION_NUMBER;%0Aimport static pl.vehicle_history.database.DbConstants.COLUMN_VIN;%0Aimport static pl.vehicle_history.database.DbConstants.TABLE_NAME;%0A%0Aimport android.content.ContentValues;%0Aimport android.content.Context;%0Aimport android.database.Cursor;%0Aimport android.database.DatabaseUtils;%0Aimport android.database.sqlite.SQLiteDatabase;%0A%0Aimport pl.vehicle_history.Search;%0A%0Apublic class SearchHistoryDb %7B%0A%0A    private HistoryDbOpenHelper historyDbHelper;%0A%0A    public SearchHistoryDb(Context context) %7B%0A        this.historyDbHelper = new HistoryDbOpenHelper(context);%0A    %7D%0A%0A    public void saveSearch(Search search) %7B%0A        SQLiteDatabase db = historyDbHelper.getWritableDatabase();%0A%0A        ContentValues values = new ContentValues();%0A        values.put(COLUMN_LABEL, search.getLabel());%0A        values.put(COLUMN_REGISTRATION_NUMBER, search.getPlate());%0A        values.put(COLUMN_VIN, search.getVin());%0A        values.put(COLUMN_REGISTRATION_DATE, search.getRegistrationDate());%0A%0A        db.insert(TABLE_NAME, null, values);%0A    %7D%0A%0A    public Search getSearch(int position) %7B%0A        SQLiteDatabase db = historyDbHelper.getReadableDatabase();%0A%0A        String%5B%5D projection = %7B%0A                COLUMN_LABEL, COLUMN_REGISTRATION_NUMBER, COLUMN_VIN, COLUMN_REGISTRATION_DATE%0A        %7D;%0A%0A        String sortOrder = COLUMN_LABEL + %22 DESC%22;%0A%0A        Cursor cursor = db.query(%0A                TABLE_NAME,%0A                projection,%0A                null,%0A                null,%0A                null,%0A                null,%0A                sortOrder%0A        );%0A%0A        cursor.moveToPosition(position);%0A%0A        String label = cursor.getString(0);%0A        String registrationNumber = cursor.getString(1);%0A        String vin = cursor.getString(2);%0A        String registrationDate = cursor.getString(3);%0A%0A        return new Search(label, registrationNumber, vin, registrationDate);%0A    %7D%0A%0A    public int getSearchesNumber() %7B%0A        SQLiteDatabase db =  historyDbHelper.getReadableDatabase();%0A%0A        return (int) DatabaseUtils.queryNumEntries(db, TABLE_NAME, null, null);%0A    %7D%0A%0A%7D%0A

Create SearchHistoryDb.