private void prepareConfiguration() throws IOException {
   databaseConfiguration.setDatabaseUrl(
       String.format(
           "jdbc:postgresql://%1$s:%2$s/%3$s",
           configuration.getHost(), configuration.getPort(), configuration.getDatabaseName()));
   databaseConfiguration.setDatabaseUser(getSystemUser());
   databaseConfiguration.setDatabasePassword(getSystemPassword());
 }
 public DataSource systemDataSource() {
   final PGSimpleDataSource dataSource = new PGSimpleDataSource();
   dataSource.setServerName(configuration.getHost());
   dataSource.setPortNumber(configuration.getPort());
   dataSource.setUser(getSystemUser());
   dataSource.setPassword(getSystemPassword());
   dataSource.setDatabaseName(configuration.getDatabaseName());
   return dataSource;
 }
 public DataSource superDataSource() {
   final PGSimpleDataSource dataSource = new PGSimpleDataSource();
   dataSource.setServerName(configuration.getHost());
   dataSource.setPortNumber(configuration.getPort());
   dataSource.setUser(configuration.getUser());
   dataSource.setPassword(configuration.getPassword());
   dataSource.setDatabaseName(POSTGRES_SUPER_DATABASE);
   return dataSource;
 }
 private DataSource sharkDataSource() {
   final PGSimpleDataSource dataSource = new PGSimpleDataSource();
   dataSource.setServerName(configuration.getHost());
   dataSource.setPortNumber(configuration.getPort());
   dataSource.setUser(SHARK_USERNAME);
   dataSource.setPassword(SHARK_PASSWORD);
   dataSource.setDatabaseName(configuration.getDatabaseName());
   return dataSource;
 }
  @SuppressWarnings("static-access")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    this.thisActivity = getParent();
    //		mViewPager.setBackgroundColor(android.graphics.Color.GRAY);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    File file = new File(Environment.getExternalStorageDirectory() + "/jarvise.txt");
    if (!file.exists()) {
      try {
        file.createNewFile();
        BufferedWriter br = new BufferedWriter(new FileWriter(file));
        br.write("host address / ip address");
        br.write("\n");
        br.write("username");
        br.write("\n");
        br.write("password");
        br.write("\n");
        br.write("default1");
        br.write("\n");
        br.write("default2");
        br.write("\n");
        br.write("default3");
        br.write("\n");
        br.write("default4");
        br.write("\n");
        br.flush();
        br.close();
      } catch (IOException e) {
        System.out.println("errore creazione file");
        e.printStackTrace();
      }

      this.user = config.getUser();
      this.pass = config.getPass();
      this.host = config.getHost();
      this.def1 = config.getDefault0();
      this.def2 = config.getDefault1();
      this.def3 = config.getDefault2();
      this.def4 = config.getDefault3();
    }
    actionBar = getActionBar();
    actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.carbo));
    //		actionBar.setBackgroundDrawable((new ColorDrawable(android.graphics.Color.BLUE)));

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setStackedBackgroundDrawable(getResources().getDrawable(R.drawable.layout));
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }

          @Override
          public void onPageScrolled(int arg0, float arg1, int arg2) {
            mViewPager.getParent().requestDisallowInterceptTouchEvent(true);
          }

          @Override
          public void onPageScrollStateChanged(int arg0) {

            // go back to the center allowing to scroll indefinitely
            //				                  mViewPager.setCurrentItem(1, false);
          }
        });

    // For each of the sections in the app, add a tab to the action bar.
    // Create a tab with text corresponding to the page title defined by
    // the adapter. Also specify this Activity object, which implements
    // the TabListener interface, as the callback (listener) for when
    // this tab is selected.

    actionBar.addTab(actionBar.newTab().setText("Status").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Pannello").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Personali").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Controllo").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Sensori").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Settaggi").setTabListener(this));
  }