Search code examples
javaandroidinternal-storage

How to save multiple pieces of data as one package


I am trying to save two strings and a string array together in one package to an internal storage. But I am having an issue actually combining the three together as one. Here is my code:

class Save_Constructor extends Phone_Save{

String constructor_file_name;
String constructor_class_name;
String[] constructor_notes_to_attach;

    Save_Constructor(){
        constructor_file_name = file_name; constructor_class_name=name; constructor_notes_to_attach=text;


    }

    }

Ideally, I would like to compress these three elements into one, and return them back to the Phone_Save class to be saved into the Phones internal storage. Does anybody have an idea as to how to do this? Honestly I am not even sure whether or not to use a constructor for this, so I am open for any and all ideas. Thanks!


Solution

  • Just have a look at Java POJO/Bean class and try to understand it in detail. That is the solution for your problem. Just user setters and getters in your class and the use that Class's object as a single entity for your 3 different entities.

    Just a quick google search and I got this for you.

    Comment below if you dont understand anything.