package com.ardrawing.ardrawingspace;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;

public class MyApplication extends Application {
    public static MyApplication application;
    public static final String DATABASE_NAME = "database";
    public static final int DATABASE_VERSION = 1;
    private static final String PREF_NAME = "preferences";
    private static final String KEY_INITIALIZED = "initRoom";

    @Override
    public void onCreate() {
        super.onCreate();

        application = this;

        SharedPreferences preferences = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
        boolean init = preferences.getBoolean(KEY_INITIALIZED, false);

        if (!init) {
            initDatabase();
            preferences.edit().putBoolean(KEY_INITIALIZED, true).apply();
        }
    }

    private void initDatabase() {
//        InitDatabase initDatabase = new InitDatabase(getContext());
//        initDatabase.insertImagesToDatabase();
    }

    public static Context getContext() {
        return application.getApplicationContext();
    }
}
