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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:45:53+00:00 2026-06-18T20:45:53+00:00

I have a pre-filled database in assets folder, which I move to internal storage

  • 0

I have a pre-filled database in assets folder, which I move to internal storage on first run. It works fine on some devices, but on some I get the following error: sqlite returned: error code = 1, msg = no such table: FTSgesla, db=/data/data/com.example.enigmar/databases/gesla
The mentioned table definately exist, so I don’t know where the problem is.

SQLiteOpenHelper code:

public static class DictionaryOpenHelper extends SQLiteOpenHelper 
{

    private final Context mHelperContext;
    private SQLiteDatabase mDatabase;

    //private static String DB_PATH="/data/data/com.example.enigmar/databases/";
    private static String DB_PATH="";
    private static final String DB_NAME = "gesla";

    DictionaryOpenHelper(Context context) 
    {
        super(context, DB_NAME, null, 1);
        //
        DB_PATH = "/data/data/" + context.getPackageName() + "/databases/";
        //
        this.mHelperContext = context;

    }

    @Override
    public void onCreate(SQLiteDatabase db)
    {


    }


    public void createDataBase() throws IOException
    {

        boolean mDataBaseExist = checkDataBase();

        if(!mDataBaseExist)
        {
            this.getReadableDatabase();
            this.close();
            new Thread(new Runnable() 
            {
                public void run()
                {
                    try 
                    {
                        copyDataBase();
                        Log.e(TAG, "createDatabase database created");
                        BAZA_NAREJENA=true;
                    } 
                    catch (IOException e) 
                    {
                        throw new RuntimeException(e);
                    }
                }
            }).start();

        }

    }

    private boolean checkDataBase()
    {

        File dbFile = new File(DB_PATH + DB_NAME);
        return dbFile.exists();

    }

    private void copyDataBase() throws IOException
    {

        InputStream mInput = mHelperContext.getAssets().open(DB_NAME);
        //final Resources resources = mHelperContext.getResources();

        String outFileName = DB_PATH + DB_NAME;

        OutputStream mOutput = new FileOutputStream(outFileName);
        //InputStream mInput = resources.openRawResource(R.raw.gesla);

        byte[] mBuffer = new byte[1024];
        int mLength;
         while ((mLength = mInput.read(mBuffer))>0)
         {
             mOutput.write(mBuffer, 0, mLength);
         }
         mOutput.flush();
         mOutput.close();
         mInput.close();

        }

    public boolean openDataBase() throws SQLException
    {

        String mPath = DB_PATH + DB_NAME;
        mDatabase = SQLiteDatabase.openDatabase(mPath, null, SQLiteDatabase.CREATE_IF_NECESSARY);
        return mDatabase != null;
    }


    @Override
    public synchronized void close() {

    if(mDatabase != null)
        mDatabase.close();

    super.close();

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }

}

}

What is wrong?

  • 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-18T20:45:54+00:00Added an answer on June 18, 2026 at 8:45 pm

    In your public void createDataBase() , you are using a Thread to copy your database in. Are you sure you have finished the copy before you try to access it? This is my working copy of the code which is very similar to yours you may want to see. Another thing is

    byte[] mBuffer = new byte[1024];
    

    try 4096 , I had problems with 1024 before.

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

Sidebar

Related Questions

I have a couple of pre-existing applications which I need to run in one
I would like to have the first input in my form pre filled in
I have a form which has fields pre-filled with a default value, like this:
I have a signup form of which most fields are pre-filled using user's Facebook
I have been trying to load my pre-filled database into my device, ive tried
I'm required to have a textbox pre-filled with some text, and want the cursor
I have a JTable of which one column is pre-filled with 30min time slots
I have a pre-made SQLite database that I am downloading from the net via
I have a project that comprises pre-build Dll modules, built some time in the
I have an iOS app that stores some data in a sqlite database. 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.