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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:02:32+00:00 2026-05-24T02:02:32+00:00

I am working on an android application. In which i have slideShows. I am

  • 0

I am working on an android application. In which i have slideShows. I am parsing these through an xml and after parsing them, saving in the SQLite DB. Majority of the slideshows are saved properly but, sometimes this happens that the slides are saved two times that is, every slide in the slideShow is saved two times obviously with different PK but same content. which should be avoided.

Partial code is here, where i am getting the slides and trying to store them in DB.

      ArrayList<SlideShowItem> slideItems = null;

      slideItems=Utils.database.getSlideItemOfUrl(Constants.StoriesTable,tempSlideShow.getFullStoryUrl().substring(0, index - 1), type);

                        if (slideItems == null) {
                            Log.d("store in DB: ", " when SlideItems == null ");

                            Log.d("SlideShow Title:   ", tempSlideShow.getTitle());
                            Log.d("SlideShow pub Date:   ", tempSlideShow.getPubDate());

                            slideItems = tempSlideShow.getSlideShow();
                            Utils.database.storeSlideItem(Constants.StoriesTable, myUrl,slideItems, type);
                            Utils.topStorySlidesArrayList = slideItems;
                            slideItems = null ;

                        } else {
                            Log.d("SlideShow Title:   ", tempSlideShow.getTitle());
                            Utils.topStorySlidesArrayList = slideItems;
                            slideItems = null ;
                        } 

and code of function storeSlideItem in DataBase is:

 public synchronized void storeSlideItem(String tableName, String, url,ArrayList<SlideShowItem> list, String type) {

    System.out.println("size of the Array list:   " + list.size());

    String newType = null;
    if (type == null) {
        newType = "List";
    }else{
        newType = type;
    }   

    ArrayList<SlideShowItem> newList = new ArrayList<SlideShowItem>();
    //newList = null;
    Iterator<SlideShowItem> iterator = list.iterator();

    while (iterator.hasNext())
    {
        SlideShowItem sSItem = iterator.next();
        if(!newList.contains(sSItem))
        {
            newList.add(sSItem);
        }  
    }

    try {
        for (int i = 0; i < newList.size(); i++) {
            SlideShowItem item = newList.get(i);
            String itemUrl = url + i;// Unique URL for the DB;
            String imgString = null;

            Log.e("Loop Counter", " time " + i);

            Drawable drawable = item.getImage();
            if (item.getBody() != null) {
                item.setBody(item.getBody().replace('\'', '`'));
                // replace as it create syntax error for storing data
            }
            if (item.getSubTitle() != null) {
                item.setSubTitle(item.getSubTitle().replace('\'', '`'));
            }

            if (drawable != null) {
                Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);

                byte[] b = baos.toByteArray();
                imgString = Base64.encodeBytes(b);
            }

            if (isOpen()) {
                myDB.execSQL("INSERT INTO " + tableName + "(" + column[1] + "," + column[2] + "," + column[3] + "," + column[4] + "," + column[6]
                        + "," + column[7] + ",type) VALUES('" + itemUrl + "','" + item.getSubTitle() + "','" + item.getBody() + "','"
                        + item.getImagePath() + "','" + item.getIndex() + "','" + imgString  + "','" + newType + "Slide')");


                if (item.getBody() != null) {
                    item.setBody(item.getBody().replace('`', '\''));// " ' "
                    // replace as it create syntax error for storing data
                }
                if (item.getSubTitle() != null) {
                    item.setSubTitle(item.getSubTitle().replace('`', '\''));
                }

                if (tableName.equals(Constants.StoriesTable)) {
                    item.setItemId(getItemID(tableName, itemUrl));
                    Utils.hashListStoriesIds.put(itemUrl, item.getItemId());

                    if (imgString != null) {
                        Utils.hashListImages.put(item.getItemId(), new Boolean(true));
                    } else {
                        Utils.hashListImages.put(item.getItemId(), new Boolean(false));
                    }
                }
            }   
        }
    } catch (Exception e) {
        Log.e("Error", "Exception: storeSlideItem type " + e.toString());
    } finally {
        closeConnection();
    }

}

Please tell me anything that can get me out of this irritating problem. Any help is appreciated.

in DB for duplication of slides the view is somewhat like:

1 abc USA 111

2 abc USA 111

and so on this was for one slide of a slideShow. if i have 3 slides in a slideshow, i’ll get 6 entries in DB each slide being saved for two times.

  • 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-24T02:02:33+00:00Added an answer on May 24, 2026 at 2:02 am

    Use HashSet instead of ArrayList

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

Sidebar

Related Questions

I am working on android application in which i have play online radio streaming.
I'm working on Android application which have two different tabhost : Main and Child.
I am working on an application for android and we since we have lots
I am working on an Android application in which I want to integrate foursquare
I m working on application in which i have to send all contacts from
I am working on an android application that requires multiple views which will overlap
I have just started working on my first Android application and am going ok.
I am new to android development. Currently i am working on an application which
I am currently working on one android application which has C2DM implementation and I
i have an android application which has a listview for listing 14 items inside

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.