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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:37:10+00:00 2026-06-03T02:37:10+00:00

I am creating a database in android using this code: public class PackageDBHelper extends

  • 0

I am creating a database in android using this code:

public class PackageDBHelper extends SQLiteOpenHelper{

//The Android's default system path of your application database.
private static String DB_PATH = "/data/data/com.myapp/databases/";

private static String DB_NAME = "my_db.db";

public SQLiteDatabase db; 

private final Context myContext;

public PackageDBHelper(Context context) {

    super(context, DB_NAME, null, 1);
    this.myContext = context;
}   
public void createDataBase() throws IOException{

    boolean dbExist = checkDataBase();

    if(dbExist){
        //do nothing - database already exist
    }else{

        //By calling this method and empty database will be created into the default system path
           //of your application so we are gonna be able to overwrite that database with our database.
        this.getReadableDatabase();  //error occurs here

        try {

            copyDataBase();

        } catch (IOException e) {

            throw new Error("Error copying database");

        }
    }

}

StackTrace:

android.database.sqlite.SQLiteDiskIOException: disk I/O error
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1668)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1684)
at android.app.ActivityThread.access$1500(ActivityThread.java:124)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:948)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.sqlite.SQLiteDiskIOException: disk I/O error
at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1849)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:197)
at com.myapp.util.PackageDBHelper.createDataBase(PackageDBHelper.java:51)

This app is on the market and I have received a few error reports. I have not been able to duplicate it on any of my devices, and the error is relatively rare. I realize the DB_PATH should probably be retrieved from the device, however that should not be effecting the call to getReadableDatabase().

Any ideas?

  • 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-03T02:37:12+00:00Added an answer on June 3, 2026 at 2:37 am

    I had the same problem with HTC Desire HD, and Galaxy S on Android 2.1

    Using the following as for DB_PATH seems to fix the problem:

    Environment.getDataDirectory() + “/data/YOUR_PACKAGE/databases/”;
    

    More details available here https://stackoverflow.com/a/4828540

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

Sidebar

Related Questions

public Drawable icon; \\ Some value in this field I am creating a database
I am using sqlite database in Android. I'm not creating any database I'm using
I'm working on creating a checkbook app for android using a database to record
I'm creating a database application using ASP.NET and I want to make a Windows
When creating my SQLite database in Android I set the database locale - db.setLocale(new
I'm developing an Android application and i'm using a Sqlite database to store some
I'm using Android's SQLite to create a database of levels, based on some files.
i am creating an app that needs a database. i created it using sqlite
When creating a SQLite database (I'm using the SQLite Manager Firefox plugin), I naturally
Can anyone alter this code to include one integer variable. Not including the database

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.