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

  • Home
  • SEARCH
  • 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 6381319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:22:49+00:00 2026-05-25T02:22:49+00:00

Im using ORMLite in my Android app. I need to persist this class, which

  • 0

Im using ORMLite in my Android app. I need to persist this class, which has a HashMap. What is a good way of persisting it? Its my first time trying to persist a HashMap, also first time with ORMLite so any advice would be greatly appreciated!

*Edit*
If that makes any difference, the Exercise class is simply a String (that also works as id in the database), and the Set class has an int id (which is also id in database), int weight and int reps.

@DatabaseTable
public class Workout {

    @DatabaseField(generatedId = true)
    int id;

    @DatabaseField(canBeNull = false)
    Date created;

    /*
     * The hashmap needs to be persisted somehow
     */
    HashMap<Exercise, ArrayList<Set>> workoutMap;

    public Workout() {          
    }
    public Workout(HashMap<Exercise, ArrayList<Set>> workoutMap, Date created){
        this.workoutMap = workoutMap;
        this.created = created;
    }

    public void addExercise(Exercise e, ArrayList<Set> setList) {
        workoutMap.put(e, setList);
    }
    ... 
}
  • 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-05-25T02:22:50+00:00Added an answer on May 25, 2026 at 2:22 am

    Wow. Persisting a HashMap whose value is a List of Sets. Impressive.

    So in ORMLite you can persist any Serializable field. Here’s the documentation about the type and how you have to configure it:

    http://ormlite.com/docs/serializable

    So your field would look something like:

    @DatabaseField(dataType = DataType.SERIALIZABLE)
    Map<Exercise, List<Set>> workoutMap;
    

    Please note that if the map is at all large then this will most likely not be very performant. Also, your Exercise class (and the List and Set classes) need to implement Serializable.

    If you need to search this map, you might consider storing the values in the Set in another table in which case you might want to take a look at how ORMLite persists “foreign objects”.

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

Sidebar

Related Questions

Using C#, I need a class called User that has a username, password, active
I have a class which I want to persist with OrmLite and it stores
I am programming an Android app and using ormLite for the database. I want
I'm using ORMLite, with the Table RecentSearch : @DatabaseTable(tableName = LocalStorageConfig.SQL_RECENTS_TABLE_NAME) public class RecentSearch
Using the below XML, I need to figure out which person worked more hours
Is there a native way of escaping strings for Ormlite for Android? For example,
I'm just trying to setup my Android Project with ORMLite. I'm using Roboguice for
using CodeIgniter normally one has to specify the controllers in the config/routes.php file. This
I'm using ORMLite & SQLite as my database, and I'm working on a android
I'm using ormlite for Android and I'm trying to get a multiple column unique-constraint.

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.