// Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static JsonObject kcQuestInfoData = new JsonObject();
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_EXPCRNT = "key_expcrnt";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_EXPTDAY = "key_exptday";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_EXPTIME = "key_exptime";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_QUESTNCHK = "key_questnchk";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_SHIPIFNO = "key_shipinfo";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String ERROR_TYPE_DB = "D";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String ERROR_TYPE_VPN = "V";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Calendar getJapanCalendarInstance() {
//     Calendar c = Calendar.getInstance(TimeZone.getTimeZone("Asia/Tokyo"), Locale.JAPAN);
//     c.setFirstDayOfWeek(Calendar.MONDAY);
//     return c;
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static SimpleDateFormat getJapanSimpleDataFormat(String format) {
//     SimpleDateFormat dateFormat = new SimpleDateFormat(format, Locale.US);
//     dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Tokyo"));
//     return dateFormat;
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
//     StringWriter errors = new StringWriter();
//     ex.printStackTrace(new PrintWriter(errors));
//     return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }


import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteStatement;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import com.google.gson.stream.JsonReader;
import org.json.JSONObject;
import java.io.StringReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
import static android.R.attr.timeZone;
import static android.R.attr.value;
import static android.icu.lang.UCharacter.GraphemeClusterBreak.L;
import static com.antest1.kcanotify.KcaApiData.kcQuestInfoData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_EXPCRNT;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_EXPTDAY;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_EXPTIME;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_QUESTNCHK;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_SHIPIFNO;
import static com.antest1.kcanotify.KcaConstants.ERROR_TYPE_DB;
import static com.antest1.kcanotify.KcaConstants.ERROR_TYPE_VPN;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaUtils.getJapanCalendarInstance;
import static com.antest1.kcanotify.KcaUtils.getJapanSimpleDataFormat;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
            if (full) {
                request = c.getString(c.getColumnIndex("request"));
                data = c.getString(c.getColumnIndex("data"));
                timestamp = c.getString(c.getColumnIndex("ts"));
                log_list.add(KcaUtils.format("[%s]\t%s\t%s\t%s\t%s\t%s\t%s", type, version, url, error, request, data, timestamp));
            } else {
                String recent_indicate = version.equals(BuildConfig.VERSION_NAME) ? "*" : "";
                log_list.add(KcaUtils.format("[%s%s]\t%s\t%s", type, recent_indicate, url, error));
            }
        }
        c.close();
        return log_list;
    }

    public void clearErrorLog() {
        SQLiteDatabase db = this.getWritableDatabase();
        db.delete(error_table_name, null, null);
    }

    // for kca_userdata
    public String getValue(String key) {
        String value = null;
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor c = db.query(table_name, null, "KEY=?", new String[]{key}, null, null, null, null);
        try {
            if (c != null && c.getCount() > 0) {
                c.moveToFirst();
                value = c.getString(c.getColumnIndex("VALUE"));
            }
        } catch (Exception e) {
// Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static JsonObject kcQuestInfoData = new JsonObject();
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_EXPCRNT = "key_expcrnt";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_EXPTDAY = "key_exptday";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_EXPTIME = "key_exptime";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_QUESTNCHK = "key_questnchk";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String DB_KEY_SHIPIFNO = "key_shipinfo";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String ERROR_TYPE_DB = "D";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String ERROR_TYPE_VPN = "V";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Calendar getJapanCalendarInstance() {
//     Calendar c = Calendar.getInstance(TimeZone.getTimeZone("Asia/Tokyo"), Locale.JAPAN);
//     c.setFirstDayOfWeek(Calendar.MONDAY);
//     return c;
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static SimpleDateFormat getJapanSimpleDataFormat(String format) {
//     SimpleDateFormat dateFormat = new SimpleDateFormat(format, Locale.US);
//     dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Tokyo"));
//     return dateFormat;
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
//     StringWriter errors = new StringWriter();
//     ex.printStackTrace(new PrintWriter(errors));
//     return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }


// Path: app/src/main/java/com/antest1/kcanotify/KcaDBHelper.java
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteStatement;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import com.google.gson.stream.JsonReader;
import org.json.JSONObject;
import java.io.StringReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
import static android.R.attr.timeZone;
import static android.R.attr.value;
import static android.icu.lang.UCharacter.GraphemeClusterBreak.L;
import static com.antest1.kcanotify.KcaApiData.kcQuestInfoData;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_EXPCRNT;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_EXPTDAY;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_EXPTIME;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_QUESTNCHK;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_SHIPIFNO;
import static com.antest1.kcanotify.KcaConstants.ERROR_TYPE_DB;
import static com.antest1.kcanotify.KcaConstants.ERROR_TYPE_VPN;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaUtils.getJapanCalendarInstance;
import static com.antest1.kcanotify.KcaUtils.getJapanSimpleDataFormat;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;

            if (full) {
                request = c.getString(c.getColumnIndex("request"));
                data = c.getString(c.getColumnIndex("data"));
                timestamp = c.getString(c.getColumnIndex("ts"));
                log_list.add(KcaUtils.format("[%s]\t%s\t%s\t%s\t%s\t%s\t%s", type, version, url, error, request, data, timestamp));
            } else {
                String recent_indicate = version.equals(BuildConfig.VERSION_NAME) ? "*" : "";
                log_list.add(KcaUtils.format("[%s%s]\t%s\t%s", type, recent_indicate, url, error));
            }
        }
        c.close();
        return log_list;
    }

    public void clearErrorLog() {
        SQLiteDatabase db = this.getWritableDatabase();
        db.delete(error_table_name, null, null);
    }

    // for kca_userdata
    public String getValue(String key) {
        String value = null;
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor c = db.query(table_name, null, "KEY=?", new String[]{key}, null, null, null, null);
        try {
            if (c != null && c.getCount() > 0) {
                c.moveToFirst();
                value = c.getString(c.getColumnIndex("VALUE"));
            }
        } catch (Exception e) {
            recordErrorLog(ERROR_TYPE_DB, "getValue", key, "", getStringFromException(e));