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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:00:14+00:00 2026-06-01T20:00:14+00:00

I have an application in which I am updating my SQLite db file, but

  • 0

I have an application in which I am updating my SQLite db file, but every time when the user uninstalls this application this db file is deleted and at reinstallation a new db file is created. I want to copy this db file after every update to a micro SD card so that after uninstallation I could be able to access my database.

Goal
Copy every time when db file is updated

  1. say text.db when created
  2. now I want to copy this db file to micro SD card
  3. this db file (application db file) is being updated
  4. now copy and replace this db file to micro sd card
  • 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-01T20:00:16+00:00Added an answer on June 1, 2026 at 8:00 pm

    Sudo code to copy the database to SD-Card. To copy it back, simply reverse the streams.

             public boolean copyDatabase() {
                String SDCardPath = Environment.getExternalStorageDirectory().getAbsolutePath();
                // Create the directory if neccesary.
                File directory = new File(SDCardPath  + <PATH TO SD-CARD SAVE LOCATION>);
                if (!directory.exists())
                        directory.mkdir();
    
    
                // Close the database before trying to copy it
                database.close();
    
                // Copy database to SD-card
                try {
                        InputStream mInput = new FileInputStream(<PATH TO DATABASE ON PHONE>);
                        OutputStream mOutput = new FileOutputStream(SDCardPath + <PATH TO SD-CARD SAVE LOCATION>);
    
                        byte[] buffer = new byte[1024];
                        int length;
                        while ((length = mInput.read(buffer)) > 0) {
                                mOutput.write(buffer, 0, length);
                        }
                        mOutput.flush();
                        mOutput.close();
                        mInput.close();
                } catch (Exception e) {
    
                }
    
                return database.open();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to MongoDb but have an existing application which would benefit heavily
I have a simple application which polls database for data every minute. When new
I have designed a database for an application which contains user settings. This database
I have created a web application which is creating and updating the xml file
I have an application which resides in ROOT. This application has a java class(in
I have a simple User Account application in which the user is able to
I have a Delphi application which contains a manifest file with a few dependencies
I have a three-tier application which is installed in corporate environments. With every server
Hi I have an application which checks and counts searched terms by updating a
I have currently been working on a web application which features a dynamically updating

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.