private void copyBetweenDatabases() {
    DatabaseHelper dbHelper = new DatabaseHelper(this);
    try {
      dbHelper.openDataBase(false);
    } catch (SQLException e) {
      e.printStackTrace();
    }

    List<TestContainer> list = dbHelper.getTests();
    dbHelper.close();

    DatabaseHelper.DB_NAME =
        DatabaseHelper.DB_NAME.equals(DatabaseHelper.DB_AM)
            ? DatabaseHelper.DB_RU
            : DatabaseHelper.DB_AM;
    dbHelper = new DatabaseHelper(this);

    try {
      dbHelper.openDataBase(true);
    } catch (SQLException e) {
      e.printStackTrace();
    }

    for (int i = 0; i < list.size(); i++) {
      int newDbProgress = dbHelper.getTests().get(i).getProgress();
      int oldDbProgress = list.get(i).getProgress();
      if (oldDbProgress != newDbProgress) {
        dbHelper.updateProgress(i + 1, oldDbProgress);
      }
    }
    dbHelper.close();
  }
  private void copyOldData() {
    SharedPreferences preferences = null;
    try {
      preferences = getSharedPreferences("tests", 0);
    } catch (Exception e) {

    }

    if (preferences != null) {
      DatabaseHelper db = new DatabaseHelper(this);
      try {
        db.openDataBase(true);
      } catch (SQLException e) {
        e.printStackTrace();
      }
      for (int i = 1; i <= 62; ++i) {
        String name = "Test" + String.valueOf(i);
        String percent = preferences.getString(name, null);

        if (percent != null) {
          int progress = Integer.parseInt(percent.substring(0, percent.length() - 1));
          if (progress != db.getTests().get(i - 1).getProgress()) db.updateProgress(i, progress);
        }
      }
      db.close();

      preferences.edit().clear().commit();
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    DatabaseHelper dbHelper = new DatabaseHelper(this);
    try {
      dbHelper.createDataBase();
      dbHelper.openDataBase(false);
    } catch (IOException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
    }

    copyOldData();
    dbHelper.close();
    dialogLanguage();
    setLocale(this);
    if (savedInstanceState != null) {
      position = savedInstanceState.getInt("position");
    }

    setContentView(R.layout.activity_main);

    mPager = (ViewPager) findViewById(R.id.ViewPager_mainPager);
    mPager.setOffscreenPageLimit(2);
    mPager.setAdapter(new MFragmentAdapter(getSupportFragmentManager()));
    UnderlinePageIndicator indicator =
        (UnderlinePageIndicator) findViewById(R.id.CirclePageIndicator_indicator);
    indicator.setViewPager(mPager);
    SharedPreferences pref = getSharedPreferences("reset", 0);
    position = pref.getInt("position", 0);
    mPager.setCurrentItem(position);

    testIndicatorIcon = (ImageView) findViewById(R.id.indicator_Test);
    contentIndicatorIcon = (ImageView) findViewById(R.id.indicator_Content);
    schoolInidcatorIcon = (ImageView) findViewById(R.id.indicator_Schools);
    setTitleButtons();

    testIndicatorIcon.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mPager.setCurrentItem(0);
            setTitleButtons();
          }
        });
    contentIndicatorIcon.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mPager.setCurrentItem(1);
            setTitleButtons();
          }
        });
    schoolInidcatorIcon.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mPager.setCurrentItem(2);
            setTitleButtons();
          }
        });

    indicator.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          @Override
          public void onPageSelected(int position) {

            setTitleButtons();
          }

          @Override
          public void onPageScrollStateChanged(int state) {}
        });
  }