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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:05:55+00:00 2026-06-07T18:05:55+00:00

I have a synchronism logic makes sendOrder from db in android to server by

  • 0

I have a synchronism logic makes sendOrder from db in android to server by web service which runs on doInBackgroud().

first I start app.
then click SyncClick and It Sync database without error.
after that I go into application add someorder to orderTable
return to main screen(which has SyncClick) and I click SyncClick again.
It sends order (which means sendOrder() function works well)
after that reset database and get latest data on doInBackgroud().
but It getting this error;

07-11 23:38:15.406: E/AndroidRuntime(7864): java.lang.RuntimeException: An error occured while executing doInBackground()

07-11 23:38:15.406: E/AndroidRuntime(7864): Caused by: java.lang.NullPointerException

after I start app and click SyncClick works well again. so It doesn’t work after I add some order then Sync but works well without any order added.

looking for problem.
thanks for your time in advance.

public void SyncClick(View v) 
    {
        Loading = (ImageView)findViewById(R.id.imgLoadingAnim);
        LoadingLayout = (LinearLayout)findViewById(R.id.loLoadingAnim);
        LoadingLayout.setVisibility(VISIBLE);
        Loading.setBackgroundResource(R.drawable.loading);
        frameAnimation= (AnimationDrawable)Loading.getBackground();
        frameAnimation.setCallback(Loading);
        frameAnimation.setVisible(true, true);
        frameAnimation.start();

        if(!this.dhn.isTableExists("Orders"))
        {
            updateDB();
        }

        sendOrder();    
    }


    public void sendOrder()
    {
        ArrayList<Object[]> argumentsList = new ArrayList<Object[]>();
        Object[] stuff = {this.dhn, this};
        //SEND
        ArrayList<Order> orders = this.dhn.GetOrders();

        for(int i = 0 ; i < orders.size(); i++)
        {
            ArrayList<OrderItem> orderItems = this.dhn.GetOrderItems(orders.get(i).ID);

            String orderItemsS = "";

            for(int r = 0 ; r < orderItems.size(); r++)
            {
                orderItemsS = orderItemsS + orderItems.get(r).FinalCode + "|" + orderItems.get(r).Quantity + "|" +
                orderItems.get(r).Price + "|" + orderItems.get(r).Discount + "|" + orderItems.get(r).Status + "|" + "#";
            }

            orderItemsS = orderItemsS.substring(0, orderItemsS.length() - 1);

            Object[] arguments = { 
                    new String("OrderAdd"), 
                    stuff,

                    new String("UserId"),
                    new Integer (orders.get(i).UserId),
                    new String("int"),

                    new String("CustomerId"),
                    new Integer (orders.get(i).CustomerId),
                    new String("int"),

                    new String("Price"),
                    new Double (orders.get(i).Price),
                    new String("double"),

                    new String("Discount"),
                    new Double (orders.get(i).Discount),
                    new String("double"),

                    new String("Status"),
                    new Integer (orders.get(i).Status),
                    new String("int"),

                    new String("orderItems"),
                    new String (orderItemsS),
                    new String("String")
                    };

            argumentsList.add(arguments);
        }

        Object[] stuffALL = {this.dhn, this, argumentsList};


        Object[] argumentsALL = { 
                new String("recieveALL"), 
                stuffALL
                };

        //ConnectXML runXMLALL = new ConnectXML();
        new ConnectXML().execute(argumentsALL);


        Status = 1;

        updateDB();

        receive();
    }

    public void receive()
    {
        Object[] stuff = {this.dhn, this};
        ArrayList<Object[]> argumentsList1 = new ArrayList<Object[]>();

        //receive
        Object[] arguments = { 
                new String("ProductListGet"), 
                stuff,
                new String("CatID"),
                new Integer (-1),
                new String("int")
                };
        argumentsList1.add(arguments);
        Object[] arguments1 = { 
                new String("CustomerListGet"), 
                stuff
                };
        argumentsList1.add(arguments1);
        Object[] arguments2 = { 
                new String("CategoryListGet"), 
                stuff,
                new String("ParentID"),
                new Integer (-2),
                new String("int")
                };
        argumentsList1.add(arguments2);
        Object[] arguments3 = { 
                new String("UserListGet"), 
                stuff
                };
        argumentsList1.add(arguments3);
        Object[] arguments5 = { 
                new String("ProductCategoriesListGet"), 
                stuff
                };
        argumentsList1.add(arguments5);
        Object[] arguments6 = { 
                new String("ProductOptionListGet"), 
                stuff
                };
        argumentsList1.add(arguments6);
        Object[] arguments7 = { 
                new String("FinalProductListGet"), 
                stuff
                };
        argumentsList1.add(arguments7);
        Object[] arguments8 = { 
                new String("ProductDiscountsListGet"), 
                stuff
                };
        argumentsList1.add(arguments8);
        Object[] arguments9 = { 
                new String("ProductPriceGroupListGet"), 
                stuff
                };
        argumentsList1.add(arguments9);
        Object[] arguments10 = { 
                new String("OptionListGet"), 
                stuff
                };
        argumentsList1.add(arguments10);


        Object[] stuffALL1 = {this.dhn, this, argumentsList1};


        Object[] argumentsALL1 = { 
                new String("recieveALL"), 
                stuffALL1
                };

        //ConnectXML runXMLALL1 = new ConnectXML();
        new ConnectXML().execute(argumentsALL1);
    }

    int Stat;
    int Status;
    public void LoadAnim()
    {   
        if(Status == 1)
        {
            Stat++;
            if(Stat > 0)
            {
                LoadingLayout.setVisibility(GONE);
                if(frameAnimation !=null && frameAnimation.isRunning())
                { 
                    frameAnimation.stop();
                    Stat = 0;
                    Status = 0;
                }
            }
        }
    }

    public void updateDB()
    {
        this.dhn.close();

        try {
            InputStream myInput;

                myInput = getAssets().open("sistem.db");

            // Path to the just created empty db
            String outFileName = "/data/data/sistem.ss/databases/"
                    + "sistem.db";

            // Open the empty db as the output stream
            OutputStream myOutput = new FileOutputStream(outFileName);

            // transfer bytes from the inputfile to the outputfile
            byte[] buffer = new byte[1024];
            int length;
            while ((length = myInput.read(buffer)) > 0) {
                myOutput.write(buffer, 0, length);
            }

            // Close the streams
            myOutput.flush();
            myOutput.close();
            myInput.close();
            buffer = null;
            outFileName = null;
            this.dhn.close();
            this.dhn = null;
            this.dhn = DataHelper.getDataHelper(this);
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }

LogCat

07-12 07:31:59.879: E/AndroidRuntime(2873): FATAL EXCEPTION: AsyncTask #1
07-12 07:31:59.879: E/AndroidRuntime(2873): java.lang.RuntimeException: An error occured while executing doInBackground()
07-12 07:31:59.879: E/AndroidRuntime(2873):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
07-12 07:31:59.879: E/AndroidRuntime(2873):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
07-12 07:31:59.879: E/AndroidRuntime(2873):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
07-12 07:31:59.879: E/AndroidRuntime(2873):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
07-12 07:31:59.879: E/AndroidRuntime(2873):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-12 07:31:59.879: E/AndroidRuntime(2873):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
07-12 07:31:59.879: E/AndroidRuntime(2873):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
07-12 07:31:59.879: E/AndroidRuntime(2873):     at java.lang.Thread.run(Thread.java:1096)
07-12 07:31:59.879: E/AndroidRuntime(2873): Caused by: java.lang.NullPointerException
07-12 07:31:59.879: E/AndroidRuntime(2873):     at sistem.ss.ConnectXML.doInBackground(ConnectXML.java:79)
07-12 07:31:59.879: E/AndroidRuntime(2873):     at sistem.ss.ConnectXML.doInBackground(ConnectXML.java:1)
07-12 07:31:59.879: E/AndroidRuntime(2873):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-12 07:31:59.879: E/AndroidRuntime(2873):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-12 07:31:59.879: E/AndroidRuntime(2873):     ... 4 more
  • 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-07T18:05:57+00:00Added an answer on June 7, 2026 at 6:05 pm

    I haven’t yet had a chance to work with AsyncTask, but the documentation says:

    The task can be executed only once (an exception will be thrown if a second execution is attempted.)

    That means you just need to create a new instance and execute on that one. E.g.

    new WhateverYourTaskIsCalled().execute(...);
    

    Rather than calling execute() on the instance you’ve already used.

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

Sidebar

Related Questions

I need to have ALWAYS a background service that will synchronize my Android application
I have a cache of data which is getting refreshed from an outside source,
I have multiple SVN repositories which I intend to synchronize with other SVN server
I have a an application that has 2 parts. A service which creates content.
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
Have deployed numerous report parts which reference the same view however one of them
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
I have an Ldap directory synchronised from a microsoft active directory. This Ldap contain
I have created an app which starts with a login page, after entering some

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.