So basically I have this database that is a for loop. It gives a different score every time, which I need to save to a String (or file, but I guess a string would be easier, because I need it to be empty at every new call for the database).
I want to store all the scores by going through the loop, and then adding a , after each score (to keep them seperate) but my code isn't working because a part of the code is outside the for loop. How do I fix this? Or are there better/other methods to do what I want to create?
DatabaseHandler db = new DatabaseHandler(camera.this);
List<Database> contacts = db.getAllContacts();
for (Database contact : contacts) {
String test = contact.getMP();
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
printWriter.println(test);
}
printWriter.flush();
printWriter.close();
return stringWriter.toString();