diff --git a/src/it/reyboz/bustorino/ActivityPrincipal.java b/src/it/reyboz/bustorino/ActivityPrincipal.java
--- a/src/it/reyboz/bustorino/ActivityPrincipal.java
+++ b/src/it/reyboz/bustorino/ActivityPrincipal.java
@@ -52,6 +52,8 @@
 import it.reyboz.bustorino.backend.Stop;
 import it.reyboz.bustorino.data.DBUpdateWorker;
 import it.reyboz.bustorino.data.DatabaseUpdate;
+import it.reyboz.bustorino.data.PreferencesHolder;
+import it.reyboz.bustorino.data.gtfs.GtfsDatabase;
 import it.reyboz.bustorino.fragments.*;
 import it.reyboz.bustorino.middleware.GeneralActivity;
 
@@ -76,6 +78,20 @@
         setContentView(R.layout.activity_principal);
         final SharedPreferences theShPr = getMainSharedPreferences();
 
+        //database check
+        GtfsDatabase gtfsDB = GtfsDatabase.Companion.getGtfsDatabase(this);
+
+        final int db_version = gtfsDB.getOpenHelper().getReadableDatabase().getVersion();
+        boolean dataUpdateRequested = false;
+        final int old_version = PreferencesHolder.getGtfsDBVersion(theShPr);
+        Log.d(DEBUG_TAG, "GTFS Database: old version is "+old_version+ ", new version is "+db_version);
+        if (old_version < db_version){
+            //request db update
+            dataUpdateRequested = true;
+            DatabaseUpdate.requestDBUpdateWithWork(this, true, true);
+            PreferencesHolder.setGtfsDBVersion(theShPr, db_version);
+        }
+
 
         Toolbar mToolbar = findViewById(R.id.default_toolbar);
         setSupportActionBar(mToolbar);
@@ -173,7 +189,8 @@
             requestArrivalsForStopID(busStopID);
         }
         //Try (hopefully) database update
-        DatabaseUpdate.requestDBUpdateWithWork(this, false, false);
+        if(!dataUpdateRequested)
+            DatabaseUpdate.requestDBUpdateWithWork(this, false, false);
         /*
         Watch for database update
          */
diff --git a/src/it/reyboz/bustorino/data/PreferencesHolder.java b/src/it/reyboz/bustorino/data/PreferencesHolder.java
--- a/src/it/reyboz/bustorino/data/PreferencesHolder.java
+++ b/src/it/reyboz/bustorino/data/PreferencesHolder.java
@@ -28,7 +28,18 @@
  */
 public abstract class PreferencesHolder {
 
+    public static final String PREF_GTFS_DB_VERSION = "gtfs_db_version";
+
     public static SharedPreferences getMainSharedPreferences(Context context){
         return context.getSharedPreferences(context.getString(R.string.mainSharedPreferences), MODE_PRIVATE);
     }
+
+    public static int getGtfsDBVersion(SharedPreferences pref){
+        return pref.getInt(PREF_GTFS_DB_VERSION,-1);
+    }
+    public static void setGtfsDBVersion(SharedPreferences pref,int version){
+        SharedPreferences.Editor ed = pref.edit();
+        ed.putInt(PREF_GTFS_DB_VERSION,version);
+        ed.apply();
+    }
 }
diff --git a/src/it/reyboz/bustorino/data/gtfs/GtfsDatabase.kt b/src/it/reyboz/bustorino/data/gtfs/GtfsDatabase.kt
--- a/src/it/reyboz/bustorino/data/gtfs/GtfsDatabase.kt
+++ b/src/it/reyboz/bustorino/data/gtfs/GtfsDatabase.kt
@@ -43,15 +43,18 @@
 
     abstract fun gtfsDao() : GtfsDBDao
 
+
     companion object{
         @Volatile
         private var INSTANCE: GtfsDatabase? =null
 
+        const val DB_NAME="gtfs_database"
+
         fun getGtfsDatabase(context: Context): GtfsDatabase{
             return INSTANCE ?: synchronized(this){
                 val instance = Room.databaseBuilder(context.applicationContext,
                     GtfsDatabase::class.java,
-                    "gtfs_database")
+                    DB_NAME)
                         .addMigrations(MIGRATION_1_2)
                         .build()
                 INSTANCE = instance
@@ -77,9 +80,8 @@
             it.execSQL("CREATE TABLE IF NOT EXISTS `mato_patterns` (`pattern_name` TEXT NOT NULL, `pattern_code` TEXT NOT NULL, `pattern_hash` TEXT NOT NULL, `pattern_direction_id` INTEGER NOT NULL, `pattern_route_id` TEXT NOT NULL, `pattern_headsign` TEXT, `pattern_polyline` TEXT NOT NULL, `pattern_polylength` INTEGER NOT NULL, PRIMARY KEY(`pattern_code`), FOREIGN KEY(`pattern_route_id`) REFERENCES `routes_table`(`route_id`) ON UPDATE NO ACTION ON DELETE CASCADE )")
             it.execSQL("CREATE TABLE IF NOT EXISTS `patterns_stops` (`pattern_gtfs_id` TEXT NOT NULL, `stop_gtfs_id` TEXT NOT NULL, `stop_order` INTEGER NOT NULL, PRIMARY KEY(`pattern_gtfs_id`, `stop_gtfs_id`, `stop_order`), FOREIGN KEY(`pattern_gtfs_id`) REFERENCES `mato_patterns`(`pattern_code`) ON UPDATE NO ACTION ON DELETE CASCADE )")
 
-
         }
 
 
     }
 }
\ No newline at end of file
diff --git a/src/it/reyboz/bustorino/fragments/ScreenBaseFragment.java b/src/it/reyboz/bustorino/fragments/ScreenBaseFragment.java
--- a/src/it/reyboz/bustorino/fragments/ScreenBaseFragment.java
+++ b/src/it/reyboz/bustorino/fragments/ScreenBaseFragment.java
@@ -16,7 +16,7 @@
 
 public abstract class ScreenBaseFragment extends Fragment {
 
-    protected String PREF_FILE= BuildConfig.APPLICATION_ID+".fragment_prefs";
+    protected final String PREF_FILE= BuildConfig.APPLICATION_ID+".fragment_prefs";
 
     protected void setOption(String optionName, boolean value) {
         Context mContext = getContext();
diff --git a/src/test/java/it/reyboz/bustorino/util/LinesNameSorterTest.java b/src/test/java/it/reyboz/bustorino/util/LinesNameSorterTest.java
new file mode 100644
--- /dev/null
+++ b/src/test/java/it/reyboz/bustorino/util/LinesNameSorterTest.java
@@ -0,0 +1,31 @@
+package it.reyboz.bustorino.util;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class LinesNameSorterTest {
+
+
+
+    @Test
+    public void compare() {
+
+        final LinesNameSorter sorter = new LinesNameSorter();
+
+
+        assertTrue(sorter.compare("13N","130") < 0);
+
+    }
+
+    @Test
+    public void lineeStrane() {
+
+        final LinesNameSorter sorter = new LinesNameSorter();
+
+
+        assertTrue(sorter.compare("3 "," 8") < 0);
+
+
+    }
+}
\ No newline at end of file