Note that there are some explanatory texts on larger screens.

plurals
  1. POFiles not being written to device
    primarykey
    data
    text
    <p>I have been trying a hundred different methods to solve my problem, but for some reason they simple won't work. I'm trying to make a quick and dirty way, for my application to be persistent. It basically got a lot of objects it needs to save when destroying, so I thought I would make it put the objects into an ArrayList, and then write the ArrayList to the file using an ObjectOutputStream. </p> <pre><code>public void onStop() { super.onStop(); Log.d("Event", "Stopped"); FileOutputStream fos = null; ObjectOutputStream oos = null; try { fos = openFileOutput("Flights", MODE_WORLD_WRITEABLE); oos = new ObjectOutputStream(fos); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ArrayList&lt;Flight&gt; alFlightList = new ArrayList&lt;Flight&gt;(); Iterator it = flightMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry)it.next(); alFlightList.add((Flight) pairs.getValue()); } try { oos.writeObject(alFlightList); oos.close(); } catch (IOException e) { e.printStackTrace(); } finally { Log.d("Info", "File created!"); } } </code></pre> <p>I got a similar algorithm for reading it out again, but it complains about there not being any file to read from. I know using files for persistence is not the best practice, but this is as previously mentioned, supposed to have been a quick and dirty solution. (But the time I have used on it now, might as well have been spent on making a database. ._.) Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload