@@ -0,0 +1,2563 @@
+package edu.berkeley.eecs.cfc_tracker.log;%0A%0Aimport android.content.ContentValues;%0Aimport android.content.Context;%0Aimport android.database.Cursor;%0Aimport android.database.sqlite.SQLiteDatabase;%0Aimport android.database.sqlite.SQLiteOpenHelper;%0Aimport android.os.Environment;%0Aimport android.widget.Toast;%0A%0Aimport java.io.File;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.PrintStream;%0Aimport java.util.logging.StreamHandler;%0A%0A/**%0A * Created by shankari on 7/16/15.%0A */%0Apublic class DatabaseLogHandler extends SQLiteOpenHelper %7B%0A    private String TABLE_LOG = %22logTable%22;%0A    private String KEY_LINE = %22log_line%22;%0A    private String KEY_ID = %22ID%22;%0A    private static final int DATABASE_VERSION = 1;%0A%0A    private Context cachedContext;%0A%0A    public DatabaseLogHandler(Context context) %7B%0A        super(context, %22logDB%22, null, DATABASE_VERSION);%0A        cachedContext = context;%0A    %7D%0A%0A    @Override%0A    public void onCreate(SQLiteDatabase sqLiteDatabase) %7B%0A        String CREATE_LOG_TABLE = %22CREATE TABLE %22 + TABLE_LOG +%22 (%22 +%0A                KEY_ID + %22 INTEGER PRIMARY_KEY, %22+ KEY_LINE +%22 TEXT)%22;%0A        System.out.println(%22CREATE_CLIENT_STATS_TABLE = %22 + CREATE_LOG_TABLE);%0A        sqLiteDatabase.execSQL(CREATE_LOG_TABLE);%0A    %7D%0A%0A    @Override%0A    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) %7B%0A        sqLiteDatabase.execSQL(%22DROP TABLE IF EXISTS %22 + TABLE_LOG);%0A        onCreate(sqLiteDatabase);%0A    %7D%0A%0A    public void log(String line) %7B%0A        SQLiteDatabase db = this.getWritableDatabase();%0A        ContentValues cv = new ContentValues();%0A        cv.put(KEY_LINE, line);%0A        db.insert(TABLE_LOG, null, cv);%0A        db.close();%0A    %7D%0A%0A    public void export() %7B%0A        SQLiteDatabase db = this.getReadableDatabase();%0A        try %7B%0A            String ourFileName = Log.getLogBase(cachedContext) + %22/dumped_log_file.txt%22;%0A            System.out.println(%22ourFileName = %22+ourFileName);%0A            PrintStream out = new PrintStream(new FileOutputStream(ourFileName, true));%0A            String queryString = %22SELECT * from %22 + TABLE_LOG;%0A            Cursor cur = db.rawQuery(queryString, null);%0A            int resultCount = cur.getCount();%0A            if (cur.moveToFirst()) %7B%0A                for (int i = 0; i %3C resultCount; i++) %7B%0A                    out.println(cur.getString(0));%0A                %7D%0A            %7D%0A        %7D catch (IOException e) %7B%0A            Toast.makeText(cachedContext, e.getMessage(), Toast.LENGTH_LONG).show();%0A            System.err.println();%0A        %7D%0A        db.close();%0A    %7D%0A%7D%0A

Add a new database oriented logger