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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:48:00+00:00 2026-06-14T16:48:00+00:00

Possible Duplicate: Android backup/restore: how to backup an internal database? I am developing an

  • 0

Possible Duplicate:
Android backup/restore: how to backup an internal database?

I am developing an app in which there is SQL lite db. I need to give the user the ability to back up the database and restore it again. How can I do that? Sample code?

And in case my user saved the db, and then upgraded the app to a new DB version code, will restore work? How do I go about that?

  • 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-14T16:48:02+00:00Added an answer on June 14, 2026 at 4:48 pm

    In the folder “/data/data/’your.app.package’/databases/” you have a .db file that is your database. You can copy that file, save it, and then place it back there again.

    One example on how to backup the database to the external storage:

        final String inFileName = "/data/data/<your.app.package>/databases/foo.db";
        File dbFile = new File(inFileName);
        FileInputStream fis = new FileInputStream(dbFile);
    
        String outFileName = Environment.getExternalStorageDirectory()+"/database_copy.db";
    
        // Open the empty db as the output stream
        OutputStream output = new FileOutputStream(outFileName);
    
        // Transfer bytes from the inputfile to the outputfile
        byte[] buffer = new byte[1024];
        int length;
        while ((length = fis.read(buffer))>0){
            output.write(buffer, 0, length);
        }
    
        // Close the streams
        output.flush();
        output.close();
        fis.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Android access to remote SQL database I am going to make android
Possible Duplicate: Android HttpClient and HTTPS I want to write app on Android which
Possible Duplicate: Android:How to write to SQL database I enter data into a form
Possible Duplicate: Android ImageButton with a selected state? I was wondering whether there is
Possible Duplicate: Android Button: set onClick background image change with XML? I need that
Possible Duplicate: Android Layout and positioning issue Design layout which support for all kind
Possible Duplicate: Android GridView reorder elements via Drag and Drop Can anyone give me
Possible Duplicate: android pressing back button should exit the app I'm building a register
Possible Duplicate: Android HttpClient : NetworkOnMainThreadException Im having troubles to create an android app
Possible Duplicate: Android App high cpu-usage I am programming a app that has 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.