@@ -0,0 +1,2444 @@
+package com.example.crashreporterlib;%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 java.util.ArrayList;%0Aimport java.util.List;%0A%0A%0A/**%0A * Created by Damien Escande on 15/09/2016.%0A */%0Apublic class DbHandler extends SQLiteOpenHelper %7B%0A    // STATIC VARS%0A    private static final int DATABASE_VERSION = 1;%0A    private static final String DATABASE_NAME = %22reports%22;%0A    private static final String TABLE_REPORTS = %22REPORTS%22;%0A%0A    public DbHandler(Context context) %7B%0A        super(context, DATABASE_NAME, null, DATABASE_VERSION);%0A    %7D%0A%0A    // Creating Tables%0A    @Override%0A    public void onCreate(SQLiteDatabase db) %7B%0A        String CREATE_CONTACTS_TABLE = %22CREATE TABLE REPORTS(id PRIMARY KEY UNIQUE AUTOINCREMENT NOT NULL, stack_trace TEXT NOT NULL, crash_date TEXT NOT NULL );%22;%0A        db.execSQL(CREATE_CONTACTS_TABLE);%0A    %7D%0A%0A    // Upgrading database, won't be used%0A    @Override%0A    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) %7B%0A        db.execSQL(%22DROP TABLE IF EXISTS%22 + TABLE_REPORTS);%0A        onCreate(db);%0A    %7D%0A    // Add a report%0A    public static void addReport(ExceptionLog report) %7B%0A        SQLiteDatabase db = new DbHandler(CrashHandler.class);%0A        ContentValues values = new ContentValues();%0A        values.put(KEY_NAME, contact.getName());%0A        values.put(KEY_PH_NO, contact.getPhoneNumber());%0A%0A        // Actually inserting%0A        db.insert(TABLE_REPORTS, null, values);%0A        db.close();%0A    %7D%0A%0A    // Getting All Contacts%0A    public List%3CExceptionLog%3E getAllReports() %7B%0A        List%3CExceptionLog%3E reportList = new ArrayList%3CExceptionLog%3E();%0A        String selectQuery = %22SELECT  * FROM %22 + TABLE_REPORTS;%0A        SQLiteDatabase db = this.getWritableDatabase();%0A        Cursor cursor = db.rawQuery(selectQuery, null);%0A%0A        if (cursor.moveToFirst()) %7B%0A            do %7B%0A                ExceptionLog report = new Contact();%0A                //report.setID(Integer.parseInt(cursor.getString(0)));%0A                report.getStacktrace(cursor.getString(0));%0A                report.getDate(cursor.getString(1));%0A                // Adding contact to list%0A                reportList.add(report);%0A            %7D while (cursor.moveToNext());%0A        %7D%0A%0A        return null;%0A    %7D%0A%0A    public static void deleteAllReports() %7B%0A%0A    %7D%0A%7D%0A

add dbhandler