2010-11-23 8 views
1

Voici la situation. J'améliore ma base de données en ajoutant une seule colonne. La mise à niveau semble aller bien. Je peux voir la nouvelle colonne ajoutée, mais le problème est lors de la mise à niveau de mon application de l'ancienne à la nouvelle version w/new DB je ferme la force. La fermeture forcée semble se produire lors de l'accès à la nouvelle colonne. Si je fais une nouvelle installation, je n'obtiens aucune force et l'application fonctionne comme prévu.Android SQLite onUpgrade = force fermer

Mon sur upUpgrade regarde comme tel:

@Override public void onUpgrade(SQLiteDatabase notes_db, int oldVersion, int newVersion) { if (oldVersion == 29) { 
    notes_db.execSQL("ALTER TABLE Notes ADD COLUMN Priority text"); 
    notes_db.execSQL("ALTER TABLE Todo ADD COLUMN Priority text"); 
    notes_db.execSQL("ALTER TABLE Todo_keys ADD COLUMN Priority text"); } else { 
    notes_db.execSQL("DROP TABLE IF EXISTS " + NOTES_TABLE); 
    notes_db.execSQL("DROP TABLE IF EXISTS " + TODO_TABLE); 
    notes_db.execSQL("DROP TABLE IF EXISTS " + TODO_KEYS_TABLE); 
    onCreate(notes_db); }  } 

Toutes les idées seraient appréciées.

C'est là que je crois qu'il ne ...

11-23 14:37:06.210: DEBUG/AndroidRuntime(1647): Shutting down VM 
11-23 14:37:06.210: WARN/dalvikvm(1647): threadid=1: thread exiting with uncaught exception (group=0x4001d7e8) 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647): FATAL EXCEPTION: main 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647): java.lang.NullPointerException 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647):  at com.flufflydelusions.app.extensive_notes_donate.Notes$TaskSimpleCursorAdapter.getView(Notes.java:1065) 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647):  at android.widget.AbsListView.obtainView(AbsListView.java:1315) 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647):  at android.widget.ListView.measureHeightOfChildren(ListView.java:1198) 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647):  at android.widget.ListView.onMeasure(ListView.java:1109) 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647):  at android.view.View.measure(View.java:8173) 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132) 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647):  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012) 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647):  at android.widget.LinearLayout.measureVertical(LinearLayout.java:381) 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647):  at android.widget.LinearLayout.onMeasure(LinearLayout.java:304) 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647):  at android.view.View.measure(View.java:8173) 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132) 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:245) 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647):  at android.view.View.measure(View.java:8173) 
11-23 14:37:06.210: ERROR/AndroidRuntime(1647):  at android.widget.LinearLayout.measureVertical(LinearLayout.java:526) 

ligne 1065 est la déclaration de capture et priorité1 est la nouvelle colonne I ajouté ..

Chaîne priorité1 = c.getString (c. getColumnIndex (databaseHelper.DB_COLUMN_PRIORITY));

 if (priority1.equals("Low")) { 
      try { 
       String low_pref = preferences.getString("low_priority_color", "Default"); 
       if (!low_pref.equals("Default")){ 
        priority_text.setBackgroundColor(Integer.parseInt(low_pref, 16)+0xFF000000); 
        priority_text.setVisibility(View.VISIBLE); 
       } else { 
        priority_text.setBackgroundColor(0xFFFFe640); 
        priority_text.setVisibility(View.VISIBLE); 
       }} catch (Exception e) { 
        errorText = e.getMessage(); 
        themeError(); 
       }     
      } 
+0

pouvez-vous s'il vous plaît montrer le stacktrace? –

+0

Et voilà. GetView est l'endroit où il accède à la nouvelle colonne. Si je prends la déclaration de là, elle ira ... mais évidemment j'en ai besoin. – Paul

+0

ok, qu'en est-il de Notes.java et du contexte de la ligne 1065? –

Répondre

1

Fixé. Nouvelle colonne a une valeur nulle