-4

Here are my codes : http://pastebin.com/kGZY0h88

http://pastebin.com/Y0JNYjEd

Everytime I try to save something using the function writeAll(ArrayList liste), the application crash. Here are the logs :

`E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.example.naabi.listeserie, PID: 3459
                  java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.FileOutputStream android.content.Context.openFileOutput(java.lang.String, int)' on a null object reference
                      at com.example.naabi.listeserie.dao.SerialisationSerieDAO.writeAll(SerialisationSerieDAO.java:58)
                      at com.example.naabi.listeserie.descriptionMrRobot.onSaveInstanceState(descriptionMrRobot.java:260)
                      at android.app.Activity.performSaveInstanceState(Activity.java:1414)
                      at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1300)
                      at android.app.ActivityThread.callCallActivityOnSaveInstanceState(ActivityThread.java:4541)
                      at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4492)
                      at android.app.ActivityThread.-wrap19(ActivityThread.java)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1483)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:154)
                      at android.app.ActivityThread.main(ActivityThread.java:6119)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)`

I try to use the function by tilting the phone.

KishanCS
  • 1,357
  • 1
  • 19
  • 38
  • 1
    Please don't just link to your code off-site. You need to include a [mcve] in the question itself. – Mike M. Mar 09 '17 at 10:18

1 Answers1

0

SerialisationSerieDAO pojo is not a activity. Therefore your context (contexte) this case was never initialized. Use a mutator to set a context .or pass one in a constructor.

Remario
  • 3,813
  • 2
  • 18
  • 25