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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:32:04+00:00 2026-05-15T09:32:04+00:00

My question is I think quite simple but I don’t think the answer will

  • 0

My question is I think quite simple but I don’t think the answer will be…
I have quite a lot of content to have in my application to make it run properly, and I’m thinking of putting all of it in a database, and distribute it in an embeded database with the application in the market.
The only trouble is that I have no idea of how to do that.
I know that I can extract a file .db from Eclipse DDMS with the content of my database, and I suppose I need to put it in the asset folder of my application, but then how to make the application use it to regenerate the application database?
If you have any link to some code or help, that would be great.
Thanks

  • 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-15T09:32:05+00:00Added an answer on May 15, 2026 at 9:32 am

    Well to achieve what you’re asking, you could put the .db file in your assets/ directory and copy it into place the first time you start your app…..

    final String DB_DESTINATION = "/data/data/YOUR_PACKAGE_NAME/databases/MyDatabaseFile.db";
    
    // Check if the database exists before copying
    boolean initialiseDatabase = (new File(DB_DESTINATION)).exists();
    if (initialiseDatabase == false) {
    
        // Open the .db file in your assets directory
        InputStream is = getContext().getAssets().open("MyDatabaseFile.db");
    
        // Copy the database into the destination
        OutputStream os = new FileOutputStream(DB_DESTINATION);
        byte[] buffer = new byte[1024];
        int length;
        while ((length = is.read(buffer)) > 0){
            os.write(buffer, 0, length);
        }
        os.flush();
    
        os.close();
        is.close();
    }
    

    Where “initialiseDatabase” is some flag indicating if the app has been launched for the first time.

    Although, if you are looking at storing a lot of data, as you mentioned: I strongly recommend you avoid bloating the APK file with it, and use the Internet connection to download the database records (from a hosted server) after the app has been launched. This way you can show a progress bar indicating to the user why they are waiting a long time to start using the app. Making the APK especially large usually deters people from installing it in the first place.

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

Sidebar

Related Questions

i have read some topics on this, but i don't quite think it answers
I can't quite think of how to phrase the question to be precise, but
I think the question is quite self-explanatory. I want to implement a simple zoom
my question is quite simple, but I can't move on until I solve it.
my problem is quite simple, but very important in general - I think. I
This is a simple question I think. I am trying to search for the
I think the question is a bit silly, but for a newbie startup building
I think the question is pretty simple, do I need all the rest of
I think my question may be a duplicate, but I do not know what
Okay, Now admittedly this sounds like a silly question; But, I actually have a

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.