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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:57:53+00:00 2026-06-01T18:57:53+00:00

I have a zip file which I have to extract information from which I

  • 0

I have a zip file which I have to extract information from which I can take specific information . The process of taking out the information takes about .7 of a second estimated. What I did was add in an Asynchronous class inside my ListAdapter (To make multiple threads so it can also load other similar threads) and now in my Asynchronous class it makes multiple threads which causes the database add information to its pre existing information.

Now my question is “How would I make an asynchronous threading on a listadapter without causing duplicates on the database?”

Here is the code:

Map<TextView, String> authorViews=Collections.synchronizedMap(new WeakHashMap<TextView, String>());
    Map<TextView, String> dateViews=Collections.synchronizedMap(new WeakHashMap<TextView, String>());
private class PresentInformation extends AsyncTask<Context, Void, Void>{

    private TextView Tauthor;
    private TextView Tlabel;
    String position;

    String date = null;
    String author = null;

    public PresentInformation(TextView author, TextView label, String Position) {
        // TODO Auto-generated constructor stub
        this.Tauthor = author;
        this.Tlabel = label;
        this.position = Position;
    }

    @Override
    protected Void doInBackground(Context... params) {
        // TODO Auto-generated method stub


        Boolean addToDB;

        if(author_exist(Tauthor)){
            author = getAuthorFName(position);
            addToDB = false;
        }else{
            //Declare an action to test if author does exist
            authorViews.put(Tauthor, position);
            author = getAuthor(position);
            addToDB = true;
        }
        dateViews.put(Tlabel, position);
        if(date_exist(Tlabel)){
            date = db.getDate(position);
            addToDB = false;
        }else{
            dateViews.put(Tlabel, position);
            date = date/time();
            addToDB = true;
        }

        if(addToDB){//Adds to database if they don't exist
            db.addDatabase(new Database(position, author, date));
        }

        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        // TODO Auto-generated method stub
        if(author == null){
            author = "Author not found!";
        }
        if(date == null){
            date = "Date not found!";
        }
        Tlabel.setText(date);
        Tlabel.setText(author);
    }

    @Override
    protected void onPreExecute() {
        // TODO Auto-generated method stub
        Tauthor.setText("Loading author please wait...");
        Tlabel.setText("Loading date please wait...");
    }

    public Boolean author_exist(TextView tv){
        String temp = authorViews.get(tv);
        if(temp ==null)
            return true;
        return false;
    }
    public Boolean date_exist(TextView tv){
        String temp = dateViews.get(tv);
        if(temp ==null)
            return true;
        return false;
    }
}

public class IconicAdapter extends ArrayAdapter<String>{

        IconicAdapter() {
            super(main.this, R.layout.bookselection_row, R.id.Book_Title, bookLocation);
            }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            View row = null;
            if(row == null)
                row =  super.getView(position, convertView, parent);

             icon=(ImageView)row.findViewById(R.id.icon);
             author = (TextView)row.findViewById(R.id.book_Author);
             date_label = (TextView)row.findViewById(R.id.label);

             String path = bookLocation.get(position);

//               Collections(path, position, author, date_label);

            new PresentInformation(author, date_label, path).execute(main.this);

            try{
                Log.i("BookString input", bookLocation.get(position));
                loadImage.Uploader(bookLocation.get(position), icon);
            }catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
            }

            return row;
        }
    }       
  • 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-01T18:57:55+00:00Added an answer on June 1, 2026 at 6:57 pm

    Below is an example of an AsyncTask I’m using in the app I’m currently developing. I hope it helps get you on the right track.

    private class prepCombat extends AsyncTask<String, Void, String>{
            @Override
            protected String doInBackground(String... params) {
                playerBattlePrep();
                findNPC();
                return null;}
            @Override
            protected void onPostExecute(String result) {
                new layoutCombat().execute();
            }
         }
    

    Then when I want to call it…

    @Override
    protected void onResume() {     
        new pullCombatActions().execute();
        new prepCombat().execute();
        super.onResume();}
    

    To insure it doesn’t keep adding the same data some If() statements should work. Another option would be to include the data already in your database. If this is data that should always be there, having it already there when the program first runs could save you some trouble.

    I see your put statements but I’m not seeing where you tell it which row to place it.

    public void updateEntry(int rowId, String str, String cha, String wis, String dex, String name, int damId, int HPId, int npcId, int attId, int dodgeId, int dreadId, int critId) throws SQLException {
    
            ContentValues cvUpdate = new ContentValues();
            cvUpdate.put("Str", str);
            cvUpdate.put("Cha", cha);
            cvUpdate.put("Wis", wis);
            cvUpdate.put("Dex", dex);
            cvUpdate.put("Name", name);
            cvUpdate.put("StatDam", damId);
            cvUpdate.put("StatHP", HPId);
            cvUpdate.put("HP", HPId);
            cvUpdate.put("StatNpc", npcId);
            cvUpdate.put("StatAtt", attId);
            cvUpdate.put("StatDodge", dodgeId);
            cvUpdate.put("StatDread", dreadId);
            cvUpdate.put("StatCrit", critId);
            cvUpdate.put("Rank", "0");
            cvUpdate.put("Lvl", "1");
            ...
    
            ContentValues csUpdate = new ContentValues();
            csUpdate.put("PlayerHp", HPId);
            csUpdate.put("CombatFlag", "0");    
    
        dbhelper.myDataBase.update(dbhelper.SAVE_TABLE, cvUpdate, "_id" + "="  + rowId, null);
        dbhelper.myDataBase.update(dbhelper.COMBATSAVE_TABLE, csUpdate, "_id" + "="  + rowId, null);
    
        }
    

    Would be a method to setup what and where I put the data in my database. Then I can call the method by

    updateEntry(slot, String.valueOf(strNumber), String.valueOf(chaNumber), String.valueOf(wisNumber), String.valueOf(dexNumber), nameNumber, damId, HPId, npcId, attId, dodgeId, dreadId, critId);
    

    Whenever you want to preform this save you would call the above code. Likely in a doInBackground()

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

Sidebar

Related Questions

I have a 200mb zip file, which I want to extract to a temporary
I have a FileUploader class that can optionally be given a zip file which
I have a French dictionary file which I got from WinEdt.org (Zip File) .
I have zip file and I want to know which library can handle it?
I have .zip file which contain csv data. I am reading .zip file using
In one of my git projects, I have a zip file which bundles a
I have always wondered about this. So many application setups have a zip file
I have inherited some code (from zip file) from a developer and git initialzed,
I have a form where the user can upload a zip file, it works
I have a small job that takes a text file of email/zip codes and

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.