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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:29:27+00:00 2026-05-23T18:29:27+00:00

Let me start by saying that I’ve seeing that this problem and all the

  • 0

Let me start by saying that I’ve seeing that this problem and all the possible solution but I cant understand how it applies here so I have no idea where to start.

My MainActiviy checks if this is the first time the user started the application and fill the database. The onCreate on the SQL Helper creates jut the tables.

If this is the first time it runs, I invoke an AsyncTask that checks the language and then fill the database with the correct data. Everything works except that I get this exception when I try to insert something in the database. I can’t see where is the handler that is messing with the code.

Any clues would be great!

Stack is this:

07-16 19:49:06.854: ERROR/DatabaseCreatorTask(10725): Error trying to insert categories:Can't create handler inside thread that has not called Looper.prepare()
07-16 19:49:06.854: WARN/System.err(10725): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
07-16 19:49:06.854: WARN/System.err(10725):     at android.os.Handler.<init>(Handler.java:121)
07-16 19:49:06.854: WARN/System.err(10725):     at android.app.Activity.<init>(Activity.java:679)
07-16 19:49:06.854: WARN/System.err(10725):     at com.objects.Category.<init>(Category.java:19)
07-16 19:49:06.854: WARN/System.err(10725):     at tasks.DatabaseCreatorTask.fillCategoriesTable(DatabaseCreatorTask.java:58)
07-16 19:49:06.854: WARN/System.err(10725):     at tasks.DatabaseCreatorTask.doInBackground(DatabaseCreatorTask.java:89)
07-16 19:49:06.854: WARN/System.err(10725):     at tasks.DatabaseCreatorTask.doInBackground(DatabaseCreatorTask.java:1)
07-16 19:49:06.854: WARN/System.err(10725):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-16 19:49:06.854: WARN/System.err(10725):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-16 19:49:06.854: WARN/System.err(10725):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-16 19:49:06.854: WARN/System.err(10725):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
07-16 19:49:06.854: WARN/System.err(10725):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
07-16 19:49:06.854: WARN/System.err(10725):     at java.lang.Thread.run(Thread.java:1096)

This is part of my source code:

doInBackground of the AsyncTask:

protected Boolean doInBackground(Void ... strings) {

        Log.i(LOG_TAG, "doInBackground...");

        String lang = PreferencesHelper.getInstance().getSettings(context).getString("lang", "en");

        boolean resultCategories = fillCategoriesTable(lang);

        return (resultCategories);

    }

And this if the method that throws the exception:

private boolean fillCategoriesTable(String lang) {

    boolean result = true;
    Log.i(LOG_TAG, "Filling categories...");

    if (lang != null && lang.length() > 0) {

        Log.i(LOG_TAG, "Context: " + context);
        Log.i(LOG_TAG, "Language: " + lang);

        if (lang.equalsIgnoreCase("es")) {

            try {

                Category cat1 = new Category("Entretenimiento", null);
                Log.i(LOG_TAG, "Creating new category Entretenimiento:" + cat1.create(this.context));

                Category cat2 = new Category("Viajes", null);
                Log.i(LOG_TAG, "Creating new category Viajes:" + cat2.create(this.context));

                Category cat3 = new Category("Comidas", null);
                Log.i(LOG_TAG, "Creating new category Comidas:" + cat3.create(this.context));

            } catch (Exception e) {
                Log.e(LOG_TAG, "Error trying to insert categories: " + e.getMessage());
                e.printStackTrace();
                result = false;
            }

        } else {

            try {

                Category cat1 = new Category("Entertainment", null);
                Log.i(LOG_TAG, "Creating new category Entertainment:" + cat1.create(this.context));

                Category cat2 = new Category("Travel", null);
                Log.i(LOG_TAG, "Creating new category Travel:" + cat2.create(this.context));

                Category cat3 = new Category("Dining", null);
                Log.i(LOG_TAG, "Creating new category Dining:" + cat3.create(this.context));

            } catch (Exception e) {
                result = false;
                Log.e(LOG_TAG, "Error trying to insert categories:" + e.getMessage());
                e.printStackTrace();
            }

        }
    } else {
        Log.w(LOG_TAG, "Lang is null");
        result = false;
    }

    return result;

}
  • 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-23T18:29:27+00:00Added an answer on May 23, 2026 at 6:29 pm

    Your Category constructor appears to be attempting to create an instance of an Activity, or perhaps Category extends Activity. Don’t do that.

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

Sidebar

Related Questions

Let me start by saying that I do not advocate this approach, but I
Let me start by saying that this is working correctly, but I know it's
First of all let me start by saying that this question is not about
Let me start out by saying that I'm not a JavaScript developer so this
Let's start by saying that my code works perfectly fine, there is no problem
Let me start by saying that this question can possibly be answered by AI
Let me start off by saying that I am completely new with WPF (this
Let me start off by saying that this is my first real Cocoa app.
Let me start this off by saying that I'm an intern with no Powershell
First off, let me start by saying that I am totally new to working

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.