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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:49:51+00:00 2026-06-06T14:49:51+00:00

I am using strict mode for android 3.2 and am getting StrictModeDiskReadViolation during onCreate

  • 0

I am using strict mode for android 3.2 and am getting StrictModeDiskReadViolation during onCreate in my Activity.

I tried to moved the code that does an SQL query to:

  • a new Thread.
  • a new AsyncTaskLoader.
  • a new AsynTask.

The problem is only AsyncTask made the Violation dissappear and I’m wondering why the other two methods didn’t work?

Here is my code:

AsyncTask<Void, Void, Void> asyncTask = new AsyncTask<Void, Void, Void>() {

            @Override
            protected Void doInBackground(Void... params) {
                try {
                    Dao<Listino, Integer> dao = DatabaseHelper.getHelper(ListinoActivity.this).getListinoDao();
                    if (dao.countOf() == 1)
                    {
                        long id = dao.queryForAll().get(0).getId();//long non int
                        final Intent intent = new Intent(ListinoActivity.this, ListinoProdottiActivity.class);
                        intent.putExtra("listino_id", id);
                        intent.setAction(Intent.ACTION_MAIN);
                        ListinoActivity.this.finish();
                        ListinoActivity.this.startActivity(intent);
                    }
                } catch (SQLException e) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            MyToast.makeText(ListinoActivity.this, "Errore ottenere i listini", MyToast.LENGTH_SHORT).show();
                        }
                    });

                    e.printStackTrace();
                }
                return null;
            }

        };
        asyncTask.execute();

        AsyncTaskLoader async = new AsyncTaskLoader(this) {


            @Override
            public Object loadInBackground() {
                //do stuff, violation still here
                return null;
            }
        };

        async.loadInBackground();

        Thread t = new Thread() {
            @Override
            public void run() {
                super.run();
                //do stuff, violation still here

            }
        };
        t.run();
  • 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-06T14:49:52+00:00Added an answer on June 6, 2026 at 2:49 pm

    You did not fork a Thread. To fork a Thread, you call start(). You called run(), which simply ran your run() method on the current thread.

    And you did not come even close to using the Loader framework properly. The code you have there not only suffers from the same flaw as what you did with your Thread, but that is not how you use a Loader.

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

Sidebar

Related Questions

Why is this in an anonymous function undefined when using javascript in strict mode?
I have been using nxml-mode to edit XHTML. However, it does not work very
When I enabled strict SQL mode on my development box, I found a bunch
I have started using the Android StrictMode and find that it would be great
I wish to open a file using the a+b mode, i.e. if it does
I have the following code that suppose used to Send Data to Server using
I am using strict doctype and i want to embed a page within a
My site is currently using: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd> However,
I was going to start using === (triple equals, strict comparison) all the time
iframes are not supported in xhtml strict. However, in my application I am using

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.