[Solved!]How can i save data from an app in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

[Solved!]How can i save data from an app in java?

Hey there So i'm making an application for next school year for practice. Like a planner of some kind. it's gonna keep me organised aswell. Right now i have a notes tab. But i wonder how i can save the thing i type in there when i close the app and reopen it. Do i have to make an entire database or? cuz im still learning the very very very basics of that xd. its going to have a calender too, schedule,.. lots of stuff, but i wanna start if i can even save the note tab lmao. And i have a login screen, but that doesn't really need saving.

28th Jun 2020, 4:06 PM
Jordi
Jordi - avatar
5 Answers
+ 1
i think ill have to try something else. Serialization it is i suppose.
28th Jun 2020, 5:06 PM
Jordi
Jordi - avatar
28th Jun 2020, 4:40 PM
Jordi
Jordi - avatar
0
i take that back public void loadData() { try { BufferedReader br = new BufferedReader(new FileReader("saveData.txt")); notes = br.readLine(); br.close(); } catch(Exception e){ } NotesText.setText(notes); } this doesn't work...idk why. i get no errors xd.
28th Jun 2020, 5:00 PM
Jordi
Jordi - avatar
0
save Save = new save(); Save.age = 50; Save.name = "JOE"; String fileName = "data.bin"; try { ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(fileName)); os.writeObject(Save); os.close(); System.out.println("test"); } catch(IOException e) { e.printStackTrace(); } System.out.println("Done writing!"); couldn't make this work either...jesus. rip me
28th Jun 2020, 5:36 PM
Jordi
Jordi - avatar
0
nvm, the file was saved in a different folder
28th Jun 2020, 5:54 PM
Jordi
Jordi - avatar