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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:32:19+00:00 2026-06-02T06:32:19+00:00

i am fetching a data from sqlite in android which is as follows URL

  • 0

i am fetching a data from sqlite in android which is as follows

  URL                     PHONE
---------------------------------
/test/img1.png          98989898
/test/img1.png          61216121
/test/img2.png          75757575
/test/img2.png          40404040
/test/img3.png          36363636

now i want to create such a map which stores the data as follows

   /test/img1.png          [98989898 , 61216121 ]
   /test/img2.png          [75757575 , 40404040 ]
   /test/img3.png          [36363636]

so that i can pass the whole map to the function which function eventually in background pick up the image url and send the data to the arrays listed to the phone number. so how can i transform the data that i have fetched into the key to string array style ?

  • 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-02T06:32:22+00:00Added an answer on June 2, 2026 at 6:32 am

    I’d create a Map<String, List<String>> (aka “multi-map”). You don’t have to know how many phone numbers for a given URL before you start if you use List<String>. That’s not so if you choose the array route.

    Map<String, List<String>> results = new HashMap<String, List<String>>();
    while (rs.next()) {
        String url = rs.getString(1);
        String phone = rs.getString(2);
        List<String> phones = (results.contains(url) ? results.get(url) : new ArrayList<String>());
        phones.add(phone);
        results.put(url, phones);
    }
    

    Google Collections has a multi-map that you can use out of the box, but I think you’ll agree that this is sufficient.

    If you want to store more items (e.g. name) you should start thinking about an object that encapsulates all of them together into one coherent thing. Java’s an object-oriented language. You sound like you’re guilty of thinking at too low a level. Strings, primitives, and data structures are building blocks for objects. Perhaps you need a Person here:

    package model;
    
    public class Person {
        private String name;
        private Map<String, List<String>> contacts;
    
        // need constructors and other methods.  This one is key
        public void addPhone(String url, String phone) {
            List<String> phones = (this.contacts.contains(url) ? this.contacts.get(url) : new ArrayList<String>());
            phones.add(phone);
            this.contacts.put(url, phones);
        }
    }
    

    I’ll leave the rest for you.

    If you go this way, you’ll need to map a result set into a Person. But you should see the idea from the code I’ve posted.

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

Sidebar

Related Questions

i created an iPad application, in which i am fetching data from URL, when
I have a custom Android ContentProvider which stores and retrieves data from a SQLite
i have following code in which, i am fetching the data from the sqlite
I am fetching data from an sqlite database to Android mobile in a listview.
I am developing an iPhone application in which I am fetching data from a
I want to create a dynamic (fetching data from the database) XML sitemap which
I have an android application which in its main activity, data are adapted from
I have a page which is fetching data from a webservice using async call.
I'm fetching data from all 3 tables at once to avoid network latency. Fetching
I am fetching data from some tables & storing it in a variable like

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.