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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:59:15+00:00 2026-06-17T18:59:15+00:00

I am using Android Google maps v2 API and have it set up to

  • 0

I am using Android Google maps v2 API and have it set up to add markers on long click. I need a way to save these markers and reload them when the app resumes again. What will be the best way to do this? Please help

Currently I add markers as follows:

map.addMarker(new MarkerOptions().position(latlonpoint)
            .icon(bitmapDescriptor).title(latlonpoint.toString()));
  • 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-17T18:59:16+00:00Added an answer on June 17, 2026 at 6:59 pm

    I got it! I can easily do this via saving the array list of points to a file and then reading them back from file

    I do the following onPause:

    try {
        // Modes: MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITABLE
        FileOutputStream output = openFileOutput("latlngpoints.txt",
        Context.MODE_PRIVATE);
        DataOutputStream dout = new DataOutputStream(output);
        dout.writeInt(listOfPoints.size()); // Save line count
        for (LatLng point : listOfPoints) {
            dout.writeUTF(point.latitude + "," + point.longitude);
            Log.v("write", point.latitude + "," + point.longitude);
        }
        dout.flush(); // Flush stream ...
        dout.close(); // ... and close.
    } catch (IOException exc) {
        exc.printStackTrace();
    }
    

    And onResume: I do the opposite

    try {
        FileInputStream input = openFileInput("latlngpoints.txt");
        DataInputStream din = new DataInputStream(input);
        int sz = din.readInt(); // Read line count
        for (int i = 0; i < sz; i++) {
            String str = din.readUTF();
            Log.v("read", str);
            String[] stringArray = str.split(",");
            double latitude = Double.parseDouble(stringArray[0]);
            double longitude = Double.parseDouble(stringArray[1]);
            listOfPoints.add(new LatLng(latitude, longitude));
        }
        din.close();
        loadMarkers(listOfPoints);
    } catch (IOException exc) {
        exc.printStackTrace();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some trobule using Google Maps API on Android. In onLocationChanged() I create
I'm using Android and Google Maps at API level 10, and I get latitude
I have developed a simple application using SDK(Android: 3.2[API-13]) for, to display Google banners.
I am using the Google Maps API in an Android project and now I
I am a new user of google maps API in android OS. I have
I am writing an android application however I am using the google maps api
When using Google Maps Android API V2 I'm following the Google Play Services setup
I am searching for some way of using any Google API or android framework
I have been using this following tutorial regarding the Google Maps API and Google
I have a com.google.android.maps.MapView in my application. When using the normal view I do

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.