private void ensureFirstConfiguration(final DatabaseHelper mDatabaseHelper){
  if (mDatabaseHelper.getConfigurationsCount() == 0) {
    final UartConfiguration configuration=new UartConfiguration();
    configuration.setName("First configuration");
    final Command[] commands=configuration.getCommands();
    for (int i=0; i < 9; ++i) {
      final String cmd=mPreferences.getString(PREFS_BUTTON_COMMAND + i,null);
      if (cmd != null) {
        final Command command=new Command();
        command.setCommand(cmd);
        command.setActive(mPreferences.getBoolean(PREFS_BUTTON_ENABLED + i,false));
        command.setEol(0);
        command.setIconIndex(mPreferences.getInt(PREFS_BUTTON_ICON + i,0));
        commands[i]=command;
      }
    }
    try {
      final Format format=new Format(new HyphenStyle());
      final Strategy strategy=new VisitorStrategy(new CommentVisitor());
      final Serializer serializer=new Persister(strategy,format);
      final StringWriter writer=new StringWriter();
      serializer.write(configuration,writer);
      final String xml=writer.toString();
      mDatabaseHelper.addConfiguration(configuration.getName(),xml);
    }
 catch (    final Exception e) {
      Log.e(TAG,"Error while creating default configuration",e);
    }
  }
}

private void ensureFirstConfiguration ( final DatabaseHelper mDatabaseHelper ) { if ( mDatabaseHelper . getConfigurationsCount ( ) == 0 ) { final UartConfiguration configuration = new UartConfiguration ( ) ; configuration . setName ( "First configuration" ) ; final Command [ ] commands = configuration . getCommands ( ) ; for ( int i = 0 ; i < 9 ; ++ i ) { final String cmd = mPreferences . getString ( PREFS_BUTTON_COMMAND + i , null ) ; if ( cmd != null ) { final Command command = new Command ( ) ; command . setCommand ( cmd ) ; command . setActive ( mPreferences . getBoolean ( PREFS_BUTTON_ENABLED + i , false ) ) ; command . setEol ( 0 ) ; command . setIconIndex ( mPreferences . getInt ( PREFS_BUTTON_ICON + i , 0 ) ) ; commands [ i ] = command ; } } try { final Format format = new Format ( new HyphenStyle ( ) ) ; final Strategy strategy = new VisitorStrategy ( new CommentVisitor ( ) ) ; final Serializer serializer = new Persister ( strategy , format ) ; final StringWriter writer = new StringWriter ( ) ; serializer . write ( configuration , writer ) ; final String xml = writer . toString ( ) ; mDatabaseHelper . addConfiguration ( configuration . getName ( ) , xml ) ; } catch ( final Exception e ) { Log . e ( TAG , "Error while creating default configuration" , e ) ; } } }
converts the old configuration , stored in preferences , into the first xml configuration and saves it to the database . if there is already any configuration in the database this method does nothing .
