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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:42:05+00:00 2026-05-26T17:42:05+00:00

I got force close error when opening my install app, herewith i enclosed my

  • 0

I got force close error when opening my install app, herewith i enclosed my code

package my.package;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.Toast;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import java.util.Locale;
import android.app.ProgressDialog;
import android.content.Context;

public class ContentLoader extends Activity{

    private ProgressDialog pDialog;
    private Context cntxt;
    private static String DBPATH="data/data/my.package/databases/";
    private static String DBNAME="mydb.db";

    public void onCreate(Bundle b){
        super.onCreate(b);
        setContentView(R.layout.content_loader);
        cntxt = this.getApplicationContext();

        //pBar = (ProgressBar) findViewById(R.id.loader);
        //pBar.showContextMenu();
        pDialog = ProgressDialog.show(this, null, "Loading Application Content", true);
        final Handler handler = new Handler(){
            public void handleMessage(Message msg){
                pDialog.dismiss();
                Intent rem = new Intent(getApplicationContext(), mynextativity.class);              
                startActivityForResult(rem,0);
            }
        };

        Thread thread = new Thread(){
            public void run(){
                createDBOnFirstInstance();
                //checkDB();                
                handler.sendEmptyMessage(0);
            }
        };
        thread.start();
    }

    private boolean checkDB(){
        boolean found=true;
        String path = DBPATH + DBNAME;
        SQLiteDatabase checkDB=null;
        try{
            checkDB = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.OPEN_READONLY);            

        }catch(Exception e){
            found = false;
        }
        if(checkDB != null){             
            checkDB.close();
        }       
        return found;
    }

    public void createDBOnFirstInstance() throws SQLException{
        SQLiteDatabase db;
        if(checkDB()!=true){
                db = openOrCreateDatabase("mydb.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
                db.setLocale(Locale.getDefault());
                db.setVersion(1);
                db.setLockingEnabled(true);

                final String CREATE_ERR_TABLE = "CREATE TABLE Error_Log("
                                                +"Err_Id INTEGER PRIMARY KEY,"
                                                +"Err_Trace TEXT,"
                                                +"Err_Action TEXT,"
                                                +"Err_Occ_Date TEXT,"
                                                +"Err_Occ_Time TEXT)";

                db.execSQL(CREATE_ERR_TABLE);
                db.close(); 
        }   
    }   
}

When I install my app, it will create a database and table on the first occurrence I open the app, so it cause force close error. if I comment below code

final String CREATE_ERR_TABLE = "CREATE TABLE Error_Log("
                                                +"Err_Id INTEGER PRIMARY KEY,"
                                                +"Err_Trace TEXT,"
                                                +"Err_Action TEXT,"
                                                +"Err_Occ_Date TEXT,"
                                                +"Err_Occ_Time TEXT)";

                db.execSQL(CREATE_ERR_TABLE);
                db.close();

there is no force close error occurred and my app working fine. Please guide me.

  • 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-26T17:42:05+00:00Added an answer on May 26, 2026 at 5:42 pm

    You could try this

    final String CREATE_ERR_TABLE = "CREATE TABLE **IF NOT EXISTS** Error_Log ("
                                                    +"Err_Id INTEGER PRIMARY KEY **AUTOINCREMENT**,"
                                                    +"Err_Trace TEXT,"
                                                    +"Err_Action TEXT,"
                                                    +"Err_Occ_Date TEXT,"
                                                    +"Err_Occ_Time TEXT)**;**";
                    db.execSQL(CREATE_ERR_TABLE);
                    db.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In an Android application, we usually got the "Force Closed" error if we didn't
Okay, I've got my normal app which is in portrait mode. I can force
I got a script like this <?php if (file_exists(./foo.txt)) { header(Content-type: application/force-download); header(Content-length: .filesize(./foo.txt));
This code is causing ANR force close any idea how to improve this code?
I edited the code the way @CommonsWare told me i get force close when
I got an error while defining onClick event in my Layout. In my code
Got a problem with ADOMD.NET 8.0, SQL2008 and our app. It isn't giving us
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
I posted a free app and I've got a couple users who posted a
I got an Activity that when it starts, it loads an image from the

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.