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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:00:56+00:00 2026-06-18T03:00:56+00:00

I have my own Objects which I need to store for later use. The

  • 0

I have my own Objects which I need to store for later use. The User saves this object, it is turned into a JSON String, then when the User is connected to a network, the JSON String is turned back into the object operations are performed on it.

My problem is that, at run time, how do I know how to store the object?

i.e

Gson gson= new Gson();
String pointOfInterest = gson.toJson(point);
SharedPreferences.Editor sharedprefEditor = application_shared_preferences.edit();
sharedprefEditor.putString(?KEY?,pointOfInterest);

What can I use for the value of KEY? If I use an index, it will get reset every time I open or close the app, and this will replace my Objects.

Edit
Sorry I didn’t make this clear enough, the method that the above code is in can be run an arbitrary number of times and there could be several pointsOfInterest to store.

  • 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-18T03:00:58+00:00Added an answer on June 18, 2026 at 3:00 am

    First of all, if you use an index, the Preference will stay forever:

    For instance:

    sharedprefEditor.putString("JSON569",pointOfInterest);
    

    You can also save the index in an other preference; for instance separated by a column:

    sharedprefEditor.putString("indexes","569;789;852");
    

    You can, easily check if an instance exists:

    myPreference.getString("JSON789","").contentEquals("");
    

    Or get all your instances:

    for (int anIndex:indexes)
        Log.i("TAG","Current value: "+myPreference.getString("JSON"+anIndex,""));
    

    Please xplain a little bit more your question, I see no difficulties there/

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

Sidebar

Related Questions

I have an object which I first want to rotate (about its own center)
I have a Generic List object which hold below table as its own value.
I have an application where for each object the user can specify his own
I have a website that needs to store two sets of user data into
I have List where myObj has it own list of objects called example mySubObj.
I have 3 kinds of objects: Agency, BusinessUnit and Client (each with their own
I have an own Tree object implemented in PHP. Say we have a tree
I would like to make every EditText object have own title like in Pure
I have a Winforms application that generates its own PrintDocument object for printing. It
I have own project and i would like add for this class same as

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.