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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:55:08+00:00 2026-05-26T19:55:08+00:00

in my app i am trying to fetch some data from database and i

  • 0

in my app i am trying to fetch some data from database and i am showing it in a list. When i run the app in my Motorola(2.1) and in Samsung Ace(2.3) and i some of my emulators they are working fine.

But when i run in my Samsung Galaxy Tab-P7500(3.1), it shows the following error

 sqlite3_open_v2("/data/data/com.pack.store/databases/chaek.db", &handle, 6, NULL) failed
    E/SQLiteDatabase(10021): Failed to open the database. closing it.
    E/SQLiteDatabase(10021): android.database.sqlite.SQLiteDatabaseLockedException: database is locked
    E/SQLiteDatabase(10021): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
    E/SQLiteDatabase(10021): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:983)
    E/SQLiteDatabase(10021): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:956)
    E/SQLiteDatabase(10021): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1021)
    E/SQLiteDatabase(10021): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:750)
    E/SQLiteDatabase(10021): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
    E/SQLiteDatabase(10021): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:149)
    E/SQLiteDatabase(10021): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:223)
    E/SQLiteDatabase(10021): at com.pack.sp.SPTocPage.getTOC(SPTocPage.java:246)
    E/SQLiteDatabase(10021): at com.pack.sp.SPTocPage.onCreate(SPTocPage.java:82)
    E/SQLiteDatabase(10021): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
    E/SQLiteDatabase(10021): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1715)
    E/SQLiteDatabase(10021): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1767)
    E/SQLiteDatabase(10021): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
    E/SQLiteDatabase(10021): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1005)
    E/SQLiteDatabase(10021): at android.os.Handler.dispatchMessage(Handler.java:99)
    E/SQLiteDatabase(10021): at android.os.Looper.loop(Looper.java:132)
    E/SQLiteDatabase(10021): at android.app.ActivityThread.main(ActivityThread.java:4028)
    E/SQLiteDatabase(10021): at java.lang.reflect.Method.invokeNative(Native Method)
    E/SQLiteDatabase(10021): at java.lang.reflect.Method.invoke(Method.java:491)
    E/SQLiteDatabase(10021): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
    E/SQLiteDatabase(10021): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
    E/SQLiteDatabase(10021): at dalvik.system.NativeStart.main(Native Method)
    E/SQLiteOpenHelper(10021): Couldn't open chaek.db for writing (will try read-only):
    E/SQLiteOpenHelper(10021): android.database.sqlite.SQLiteDatabaseLockedException: database is locked
    E/SQLiteOpenHelper(10021): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
    E/SQLiteOpenHelper(10021): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:983)
    E/SQLiteOpenHelper(10021): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:956)
    E/SQLiteOpenHelper(10021): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1021)
    E/SQLiteOpenHelper(10021): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:750)
    E/SQLiteOpenHelper(10021): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
    E/SQLiteOpenHelper(10021): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:149)
    E/SQLiteOpenHelper(10021): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:223)
    E/SQLiteOpenHelper(10021): at com.pack.sp.SPTocPage.getTOC(SPTocPage.java:246)
    E/SQLiteOpenHelper(10021): at com.pack.sp.SPTocPage.onCreate(SPTocPage.java:82)
    E/SQLiteOpenHelper(10021): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
    E/SQLiteOpenHelper(10021): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1715)
    E/SQLiteOpenHelper(10021): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1767)
    E/SQLiteOpenHelper(10021): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
    E/SQLiteOpenHelper(10021): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1005)
    E/SQLiteOpenHelper(10021): at android.os.Handler.dispatchMessage(Handler.java:99)
    E/SQLiteOpenHelper(10021): at android.os.Looper.loop(Looper.java:132)
    E/SQLiteOpenHelper(10021): at android.app.ActivityThread.main(ActivityThread.java:4028)
    E/SQLiteOpenHelper(10021): at java.lang.reflect.Method.invokeNative(Native Method)
    E/SQLiteOpenHelper(10021): at java.lang.reflect.Method.invoke(Method.java:491)
    E/SQLiteOpenHelper(10021): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
    E/SQLiteOpenHelper(10021): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
    E/SQLiteOpenHelper(10021): at dalvik.system.NativeStart.main(Native Method)
    E/SqliteDatabaseCpp(10021): sqlite3_open_v2("/data/data/com.pack.sp/databases/chaek.db", &handle, 1, NULL) failed
    E/SQLiteDatabase(10021): Failed to open the database. closing it.
    E/SQLiteDatabase(10021): android.database.sqlite.SQLiteDatabaseLockedException: database is locked
    E/SQLiteDatabase(10021): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
    E/SQLiteDatabase(10021): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:983)
    E/SQLiteDatabase(10021): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:956)
    E/SQLiteDatabase(10021): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:233)
    E/SQLiteDatabase(10021): at com.pack.sp.SPTocPage.getTOC(SPTocPage.java:246)
    E/SQLiteDatabase(10021): at com.pack.sp.SPTocPage.onCreate(SPTocPage.java:82)
    E/SQLiteDatabase(10021): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
    E/SQLiteDatabase(10021): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1715)
    E/SQLiteDatabase(10021): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1767)
    E/SQLiteDatabase(10021): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
    E/SQLiteDatabase(10021): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1005)
    E/SQLiteDatabase(10021): at android.os.Handler.dispatchMessage(Handler.java:99)
    E/SQLiteDatabase(10021): at android.os.Looper.loop(Looper.java:132)
    E/SQLiteDatabase(10021): at android.app.ActivityThread.main(ActivityThread.java:4028)
    E/SQLiteDatabase(10021): at java.lang.reflect.Method.invokeNative(Native Method)
    E/SQLiteDatabase(10021): at java.lang.reflect.Method.invoke(Method.java:491)
    E/SQLiteDatabase(10021): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
    E/SQLiteDatabase(10021): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
    E/SQLiteDatabase(10021): at dalvik.system.NativeStart.main(Native Method)
    E/android.os.Debug(  284): Dumpstate > /data/log/dumpstate_app_error

Following is my Db class file

public class ChaekHelper extends SQLiteOpenHelper 
{
    private static final int DATABASE_VERSION = 7;
    private static final String DATABASE_NAME = "chaek.db";
    private List<Map<String, String>> ALL_TABLES = new ArrayList<Map<String, String>>();
    public ChaekHelper(Context context) 
    {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        this.onSetCreateQuery(context);
    }

    @Override
    public void onCreate(SQLiteDatabase db) 
    {
        for (int i = 0; i < ALL_TABLES.size(); i++) 
        {
            db.execSQL("CREATE TABLE IF NOT EXISTS " + ALL_TABLES.get(i).get("TABLE_NAME") + " ( "+ ALL_TABLES.get(i).get("FIELD_NAME") + " );");
        }

        // create Index table
        db.execSQL("DROP TABLE IF EXISTS dual;");
        db.execSQL("CREATE TABLE dual (idx INTEGER PRIMARY KEY, rownum TEXT);");
        db.execSQL("CREATE UNIQUE INDEX idx_rownum ON dual (rownum);");

        // create all tables
        db.beginTransaction();
        try 
        {
            for (int i = 1; i < 100; i++) {
                String idxStr = "0" + i;
                if (i > 9)
                    idxStr = idxStr.substring(1);

                db.execSQL("INSERT INTO dual (idx, rownum) VALUES (" + i + ",'" + idxStr + "');");
            }
            db.setTransactionSuccessful();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            db.endTransaction();
        }
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        for (int i = 0; i < ALL_TABLES.size(); i++) {
            db.execSQL("DROP TABLE IF EXISTS " + ALL_TABLES.get(i).get("TABLE_NAME") + ";");
        }
        onCreate(db);
    }

    private void onSetCreateQuery(Context context) {
        Map<String, String> params;

        // 1. BOOK
        params = new HashMap<String, String>();
        params.put("TABLE_NAME", context.getResources().getString(R.string.BOOK_TBL_NAME));
        params.put("FIELD_NAME", context.getResources().getString(R.string.BOOK_TBL_FIELDS));
        ALL_TABLES.add(params);

        // 2. TOC
        params = new HashMap<String, String>();
        params.put("TABLE_NAME", context.getResources().getString(R.string.TOC_TBL_NAME));
        params.put("FIELD_NAME", context.getResources().getString(R.string.TOC_TBL_FIELDS));
        ALL_TABLES.add(params);

        // 3. BOOKMARK
        params = new HashMap<String, String>();
        params.put("TABLE_NAME", context.getResources().getString(R.string.BM_TBL_NAME));
        params.put("FIELD_NAME", context.getResources().getString(R.string.BM_TBL_FIELDS));
        ALL_TABLES.add(params);
    }
}

Why it happens like this? can any one explain me about this…. i had wasted three days in this….

  • 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-26T19:55:08+00:00Added an answer on May 26, 2026 at 7:55 pm

    you try this code

    try {
            db = this.openOrCreateDatabase("chaek.db", MODE_PRIVATE, null);
            db.close();
            openDatabase();
            createTable();
        } catch (SQLException se) {
            Toast.makeText(this, se.getMessage(), 1).show();
        }
    private void openDatabase() {
        try {
    db = SQLiteDatabase.openDatabase("/data/data/com.pack.store/databases/chaek.db",
                    null, SQLiteDatabase.CREATE_IF_NECESSARY);
            //Toast.makeText(this, "DB was opened!", 1).show();
        } catch (SQLiteException e) {
            Toast.makeText(this, e.getMessage(), 1).show();
        }
    }// createDatabase
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have to write a Python app to communicate and fetch some data from a
I am trying to fetch some data from Netflix REST API from my iOS
I'm trying to encrypt some data from python (Google App Engine) and then decrypt
im trying to write an app that will display a list off lines from
I'm was trying a tutorial to get data to android from a MySQL database
hi I am trying to fetch data from link as given below http://abovestress.com/app_stress/fetch_all_detail.php?task=fetchtimefromdateanduserid&track_date=2011-08-09&tracker_user_id=374 but
In my iphone app, I am trying to fetch tweets from twitter. And I
I'm trying to fetch from Core Data records that have a startTime between two
I am trying to fetch data from DBF files from a .NET REST service.
Is it possible to Post some data from window based app to a web-server

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.