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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:54:38+00:00 2026-06-08T12:54:38+00:00

I am trying to put some data in a list of custom objects. One

  • 0

I am trying to put some data in a list of custom objects. One of the items in my main custom objects is a list of photos, containing two strings. But everytime i try to add a photo-item i get an nullpointerexception…

my code:

@Override
protected String doInBackground(Void... params) {
    String language =  Locale.getDefault().getISO3Language();
    AssetManager assetManager = getAssets();
    InputStream inputStream = null;
    try {
        inputStream = assetManager.open("MyJson.json");
    } catch (IOException e) {
        Log.e("tag", e.getMessage());
    }
    ObjectMapper objectMapper = new ObjectMapper();
    Log.i("tijdlog","start parsing" );
    try {

        List<JJsonResponse> jsonResponse = objectMapper.readValue(inputStream, new TypeReference<List<JJsonResponse>>() { });
        Log.i("tijdlog","ended json parsing" );
        final List<JJsonResponse> myGlobalVariable = jsonResponse;

        //Simple Venues maken, rest weggooien!
        List<SimpleVenue> sv = new ArrayList<SimpleVenue>();
        JJsonResponse e;
        int k =0; //indicator 1e SimpleVenue
        JVenueThemes jtheme;
        SimpleVenue tempSv;
        SimplePhotos tempPhoto;
        int selectedCounter;

        for(int i=0;i < jsonResponse.size() ;i++) {
            e = jsonResponse.get(i);
            if(e.venue.hidden == false) { //staat aan
                for(int j=0; j<e.venue.themes.size();j++) { //loop door alle themes
                    if (e.venue.themes.get(j).mobile == true) {  //als theme is true
                        jtheme = e.venue.themes.get(j);
                        sv.add(new SimpleVenue());
                        tempSv=sv.get(k);
                        tempSv.setId(k);
                        tempSv.setName(e.venue.name);
                        tempSv.setAdress(e.venue.address);
                        tempSv.setCity(e.venue.city);
                        tempSv.setPhone(e.venue.phone);
                        tempSv.setWebsite(e.venue.website);
                        tempSv.setFoursquare(e.venue.foursquare_link);
                        tempSv.setLatitude(e.venue.latitude);
                        tempSv.setLongitude(e.venue.longitude);
                        tempSv.setCategory(jtheme.icon);
                        tempSv.setIcon(jtheme.icon);
                        // language depending
                        if (language.equalsIgnoreCase("nld")){ //dutch
                            tempSv.setTip(e.venue.tip); 
                            tempSv.setTheme(jtheme.name); 
                        } else { //english
                             tempSv.setTip(e.venue.tip_en); 
                             tempSv.setTheme(jtheme.name_en); 
                        }
                        // put two (useless) photos items
                        for (int m = 0; m<2;m++) {
                            String large="pic1";
                            String medium="pic1";
                            tempSv.photos.add(new SimplePhotos(large,medium));                                    
                            k++;
                        }    
                    }
                }
            jsonResponse.remove(i); // 
            }
        }
    } catch (JsonParseException e) {
        // XXX Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // XXX Auto-generated catch block
        e.printStackTrace();
    }
    return language;
}

SimpleVenue:

public class SimpleVenue implements Serializable, Comparable<SimpleVenue>{
        /**
         * 
         */
    private static final long serialVersionUID = 1L;
    public int ID;
    public String name;
    public String category;
    public String address;
    public String city;
    public String tip;
    public String phone;
    public String website;
    public String foursquare;
    public float latitude;
    public float longtitude;
    public String theme;
    public String icon;
    public String exception;
    public List<SimplePhotos> photos;

SimplePhotos;

public class SimplePhotos implements Serializable{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    public String medium;
    public String large;


    public SimplePhotos(String vmedium,String vlarge){
        medium = vmedium;
        large = vlarge;
    }

    public void setMedium(String vmedium){
        medium = vmedium;
    }

    public void setLarge(String vlarge){
        large = vlarge;
    }

    public String getMedium(){
        return medium;
    }

    public String getLarge(){
        return large;
    }

I have no idea why this doesn’t work. I’m doing all this in an AsyncTast do in Background, could it be that it has anything to do with that?
Or am i just making some stupid mistake i can’t find. I used objectslists in objectslist before, but never had this problem. My error is on the line

tempSv.photos.add(new SimplePhotos(large,medium));

  • 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-08T12:54:40+00:00Added an answer on June 8, 2026 at 12:54 pm

    You haven’t shown the full declaration however it doesn’t appear that you are initialising the photos list within the SimpleVenue class. You need to assign an instance of a class that implements the List interface to this field. For example:

    public List<SimplePhotos> photos = new ArrayList<SimplePhotos>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to put some custom list adapters into their own classes to make
Hello everyone I've been trying to put some objects in an ASP.NET list box
I am trying to put my list of custom objects in the application class
I'm trying to put some sites i crawled into a shelve, but the shelve
I'm trying to put some specs around a new rails 3 project I am
I'm trying to put some HTML content inside <content:encoded> tags using ROME and its
In my JSF application I am trying to put some conditions in my Command
I am trying to add and image and then put some text(title) on the
I am trying to create a 5x5 grid with 2 exits and put some
I'm trying to put together a GUI for setting some pricing. There are three

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.