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 4580270
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:45:35+00:00 2026-05-21T20:45:35+00:00

I have this ConstantData class which holds my JSON indexes, I need to pass

  • 0

I have this ConstantData class which holds my JSON indexes, I need to pass them between activities with extras. But before that, I have to implement Parcelable to the objects of this class first.

My question is, how should I declare the object within my class here and put every object inside a variable?

I’m a newbie and I’m totally clueless right now. Thank you. Feel free to modify my code below.

ConstantData.java

public class ConstantData{

       public static String project_title = "project title";
       public static String organization_title = "organization title";
       public static String keyword = "keyword";
       public static String short_code = "short code";
       public static String project_description = "description";
       public static String smallImageUrl = "smallImageUrl";
       public static String bigImageUrl = "bigImageUrl";
       public static String price= "price";
       public static String country= "country";



        public static ArrayList<Project> projectsList = new ArrayList<Project>();


        public int describeContents() {
            return 0;
        }

        public void writeToParcel(Parcel out, int flags) {
            out.writeString(project_title);
            out.writeString(organization_title);
            out.writeString(keyword);
            out.writeString(short_code);
            out.writeString(project_description);
            out.writeString(smallImageUrl);
            out.writeString(bigImageUrl);
            out.writeString(price);
            out.writeString(country);
        }

        public static final Parcelable.Creator<ConstantData> CREATOR
                = new Parcelable.Creator<ConstantData>() {
            public ConstantData createFromParcel(Parcel in) {
                return new ConstantData(in);
            }

            public ConstantData[] newArray(int size) {
                return new ConstantData[size];
            }
        };

        private ConstantData(Parcel in) {
            project_title = in.readString();
            organization_title = in.readString();
            keyword = in.readString();
            short_code = in.readString();
            project_description = in.readString();
            smallImageUrl = in.readString();
            bigImageUrl = in.readString();
            price = in.readString();
            country = in.readString();
        }
    }

In case my question is not clear enough, you can look up this question: How to send an object from one Android Activity to another using Intents?

There he wrote myParcelableObject, I just don’t know how to make the parcelable object.

EDIT
Project.java

public class Project {

    public String project_title;
    public String organization_title;
    public String keyword;
    public String short_code;
    public String project_description;
    public String smallImageUrl;
    public String bigImageUrl;
    public String price;
    public String country;
 }
  • 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-21T20:45:36+00:00Added an answer on May 21, 2026 at 8:45 pm

    You need to implement the Parcelable interface

    public class ConstantData implements Parcelable {
    
        public void writeToParcel(Parcel out, int flags) {
            out.writeString(project_title);
        ....
            out.writeString(country);
            out.writeList(projectsList); // <<--
        }
    
        private ConstantData(Parcel in) {
            project_title = in.readString();
            ....
            country = in.readString();
            projectsList = in.readList();
    

    I think for the writing of the projectsList to work, the Project class also needs to implement Parcelable.

    See e.g. this class for an example.

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

Sidebar

Related Questions

I have a JSON file which is populated to an activity (Main.java). This Activity
I have this idea for a free backup application. The largest problem I need
I have this doubt from long time, When ever I write the class using
Have this scenario: public class Base { public string Name; } public Class ClassA
I have seen quite a few questions about this but cant seem to find
I have this list: <ul class=pagination> <li class=dl-nav-1 current><a href=#>Spring Training 2001</a><span class=visible><img src=img/indicator.png
I have this code in jQuery, that I want to reimplement with the prototype
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM
I have this line in a javascript block in a page: res = foo('<%=
I have this setup where in my development copy I can commit changes on

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.