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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:28:26+00:00 2026-05-24T08:28:26+00:00

I have a database (1.69 MB) in assets to need copy to internal databases

  • 0

I have a database (1.69 MB) in assets to need copy to internal databases folder. My problem is that for the first try db is copied but not with exact tables. It becomes 3072 (3kB) size in the emulator file explorer.

When I look in that db with sqlite explorer I can’t see my tables. The only table exists in db is android_metadata table with one column of my locale info.

But if I clear that db from databases and re-run the application, it seems working for this time. Why does it fail for the first try? How can I be sure it won’t happen in real devices?
Is that a bug with the emulator?

  • 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-24T08:28:27+00:00Added an answer on May 24, 2026 at 8:28 am

    finally i’ve come up the conclusion with the help of Naresh (thank you). Here the short summary:
    at the first run i was trying to copy my 1.6mb data.db file from assets to /data…/databases folder which one never existed. So

    OutputStream os = new FileOutputStream(destPath);
    

    line gave error. But after that line my dbhelper instance called getreadabledatabase which created the databases folder under specified path. Android put a db with same name but no useful data in it. In my copyDatabase method i updated it as follows:

    InputStream is = getBaseContext().getAssets().open(assetsDB);
    
                //when there is no databases folder fileoutputstream gives error,
                //we have to make sure databases folder exists
                DbAdapter temp = new DbAdapter(getApplicationContext());
                temp.open();        //gets readable database: creates databases folder containing DB_NAME db
                temp.close();       //since we don use this temp, we close
    
                //this wont give error: because path is now exists (databases folder exists)
                OutputStream os = new FileOutputStream(destPath);
    
                //copying 1K bytes at a time
                byte[] buff = new byte[1024];
    

    this is the solution i’ve come up with. By the way, former sdk’s of 2.3 assets database size should be less than 1mb. This is anohter issue and found the solution here

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

Sidebar

Related Questions

guys, I have the problem when copying database from local assets folder to /data/data/package_name/databases
I have an app receiving its data from a database in the assets folder.
I have database with many tables. In the first table, I have a field
I have a database that contains a date and we are using the MaskedEditExtender
I have a database table and one of the fields (not the primary key)
I have a general create function that submits a new user to the database
I have a pre-populated sqlite database and I need to attach this within my
I have a database named crea with a table named assets and in this
I have an SQLite database stored in the assets resources of one application used
I'm Unable to copy SQLite database from assests folder to device memory(trying on emulator).

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.