How to store a class object into Internal Memory Storage using serializable?

前端 未结 3 1532
心在旅途
心在旅途 2021-02-06 17:04

I need to store this object into the internal storage memory of the phone, and i have the

3条回答
  •  日久生厌
    2021-02-06 17:34

    change this

    out = new ObjectOutputStream(new FileOutputStream("appSaveState.data"));
    

    with

       File outFile = new File(Environment.getExternalStorageDirectory(), "appSaveState.data");
       out = new ObjectOutputStream(new FileOutputStream(outFile)); 
    

    as correctly pointed out by @e-x, the file will not be removed clearing application's data or uninstalling the app

提交回复
热议问题