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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:55:14+00:00 2026-06-05T06:55:14+00:00

I want to backup a DB, I’ve Google and found code that appears to

  • 0

I want to backup a DB, I’ve Google and found code that appears to work, but it ony backs up the DB structure and not the entries in the DB.

There are no errors reported, and also how do you export as CSV format the table?

code for backup a DB:

public void BackupDB() {
 InputStream myInput;

    try {

        myInput = new FileInputStream("/data/data/com.cecchina.mathew.lessonsDB/databases/Teaching");
        // Set the output folder on the SDcard
        File directory = new File("/mnt/sdcard/external_sd/TeachingBKup/");
        // Create the folder if it doesn't exist:
        if (!directory.exists()) 
        {
            directory.mkdirs();
        } 
        // Set the output file stream up:

        OutputStream myOutput = new FileOutputStream(directory.getPath()+ "/Teaching.backup");
        // Transfer bytes from the input file to the output file
        byte[] buffer = new byte[1024];
        int length;
        while ((length = myInput.read(buffer))>0)
        {
            myOutput.write(buffer, 0, length);
        }
        // Close and clear the streams
        myOutput.flush();

        myOutput.close();

        myInput.close();

    } catch (FileNotFoundException e) {
Toast.makeText(ourContext, "Backup Unsuccesfull file not found error!",          Toast.LENGTH_LONG).show();
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
Toast.makeText(ourContext, "Backup Unsuccesfull IO error!", Toast.LENGTH_LONG).show();
// TODO Auto-generated catch block
        e.printStackTrace();
    }
Toast.makeText(ourContext, "DataBase structure backed up!", Toast.LENGTH_LONG).show();

} 

Suggest me where I am lacking?

  • 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-05T06:55:16+00:00Added an answer on June 5, 2026 at 6:55 am

    If you create the backup before you have inserted any data, of course all you get is the structure (as you put it).

    Your code copies a complete file, so if there is data in the database, it is getting copied to the card.

    I use pretty much the same code (launched from a menu item) to perform backups in several of my apps. I also have code to restore/import, and when I do all my data is there.

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

Sidebar

Related Questions

I want to backup the database as gzip, but it doesn't work. This is
I want to write a code to backup my Sql Server 2008 Database using
I want to backup my web site regularly but instead of backup my files
I want not only the Create table statements, but also the Inserts. What flags
i want to backup firebird database. Below is command that i use to execute
I want to backup my database using mysql dump. This is the code I
I want to implement a backup feature in the app I'm working on, that
I want to implement a sort of backup feature for my backup app, but
I want to make a database backup with this C# code: connect = new
I want to make a backup to my database, but before writing to 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.