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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:19:56+00:00 2026-06-12T17:19:56+00:00

I know that in order to access the data folder on the device, it

  • 0

I know that in order to access the data folder on the device, it needs to be rooted. However, if I just want to copy the database from my assets folder to the data folder on my device, will the copying process works on an unrooted phone? The following is my Database Helper class. From logcat, I can verify that the methods call to copyDataBase(), createDataBase() and openDataBase() are returned successfully. However, I got this error message

android.database.sqlite.SQLiteException: no such table: TABLE_NAME:

when my application is executing rawQuery. I’m suspecting the database file is not copied successfully (cannot be too sure as I do not have access to data folder), yet the method call to copyDatabase() are not throwing any exception. What could it be? Thanks.

ps: My device is still unrooted, I hope it is not the main cause of the error.

public DatabaseHelper(Context context) {

        super(context, DB_NAME, null, 1);
        this.myContext = context;
    }   

 public void createDataBase() throws IOException{

        boolean dbExist = checkDataBase();

        String s = new Boolean(dbExist).toString();
        Log.d("dbExist", s );

        if(dbExist){
            //do nothing - database already exist
            Log.d("createdatabase","DB exists so do nothing");
        }else{


        this.getReadableDatabase();

            try {

                copyDataBase();
                Log.d("copydatabase","Successful return frm method call!");

            } catch (IOException e) {

                throw new Error("Error copying database");

            }
        }

    }


    private boolean checkDataBase(){

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


    private void copyDataBase() throws IOException{

        //Open your local db as the input stream
        InputStream myInput = null;


            myInput = myContext.getAssets().open(DB_NAME);


            Log.d("copydatabase","InputStream successful!");


        // Path to the just created empty db
        String outFileName = DB_PATH + DB_NAME;


        //Open the empty db as the output stream
        OutputStream myOutput = new FileOutputStream(outFileName);

        //transfer bytes from the inputfile to the outputfile
        byte[] buffer = new byte[1024];
        int length;
        while ((length = myInput.read(buffer))>0){
            myOutput.write(buffer, 0, length);
        }

        //Close the streams
        myOutput.flush();
        myOutput.close();
        myInput.close();

    }

    public void openDataBase() throws SQLException{

        //Open the database
        String myPath = DB_PATH + DB_NAME;
        myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);

    }

/*    @Override
    public synchronized void close() {

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

            super.close();

    }*/

    public void close() {
        // NOTE: openHelper must now be a member of CallDataHelper;
        // you currently have it as a local in your constructor
        if (myDataBase != null) {
            myDataBase.close();
        }
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

    }

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

    }



}
  • 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-12T17:19:57+00:00Added an answer on June 12, 2026 at 5:19 pm

    I assume that your DB_NAME is not the same to the Database which exists in your assests folder.

    If you are following reigndesign, then check this line:

    private static String DB_NAME ="myDBName";  
    

    DB_NAME here is the name of your database. It is assumed that you have a copy of the database in the assets folder. Your DB_NAME must be the same which exists in the assets folder.

    OR

    Follow this.

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

Sidebar

Related Questions

I know that in order to download a cookie associated with an account using
I know that in order to programmatically add my own taxonomy to a node
I know that in order for me to force the app to be in
1) I know there are lots of web sites that describe in what order
I know that Java have its own garbage collection, but sometimes I want to
I want to associate custom data to a Type, and retrieve that data in
I'm trying to use JQuery's $.getJSON to access Model data from the Controller, and
I am having problems copying data from my device back to the host. My
I'm interested in getting access to a full WHOIS database in order to expand
First of all, I know that I should not use an SQLite database to

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.