Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8934547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:48:47+00:00 2026-06-15T09:48:47+00:00

I have an ArrayList of Persons (ArrayList<Person>) , I want to store that ArrayList

  • 0

I have an ArrayList of Persons (ArrayList<Person>), I want to store that ArrayList in a persistent data type. SharedPreferences are a solution BUT it’s just manipulating String, int, float`… variables. Do you have some ideas?
Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:48:52+00:00Added an answer on June 15, 2026 at 9:48 am

    Much simpler is to use java Serialisation.

    You just need an Persons class:

    public class Persons {
    
      ArrayList<Person> personList;
    }
    

    Then simply use

    // init Persons
    Persons person = new Persons();
    // add some
    persons.personList.add(new Person());
    
    // write out
    ObjectOutpuStream oos = new ObjectOutputStream(new BufferOutputStream(new FileOutputStream("personsDB.ser")));
    
    oos.writeObject(persons);
    oos.close();
    

    read back with

    ObjectInputStream ois = new ObjectInputStream(new BufferedInpuStream(new FileInpuStream("personsDB.ser")));
    persons = (Persons) ois.readObject();
    ois.close();
    // ready! Java does that all for you; since Persons is one object which contains something
    

    The disadvantage is when battery power is lost during writing. Some people write to a temporary file first, delete the old and rename to the correct file name.

    For high performance (much less space, much faster)
    You could use DataOutputStream, but then you have to write all fields yourself (but this is simple too)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ArrayList<Person> persons . I want to check if some person in
I have an arraylist that gets different type of values in it, 1st value->
I have a program that add persons to an arraylist. What I'm trying to
I have an ArrayList called participatingUsers. Person has Person.money and Person.name that are interesting.
I have arraylist myorderdata . I want to retrieve this arraylist to one String
I have two arraylist with a number of model objects.I want to find the
I have one class that declares an enumeration type as: public enum HOME_LOAN_TERMS {FIFTEEN_YEAR,
I have a Personnel class, where I store all of Objects of type student,
I have some code that performs a deep copy using Object.clone, but I'm trying
I want to add both String and Integer type of value in ArrayList. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.