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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:19:46+00:00 2026-06-17T23:19:46+00:00

I have an app with a backup and restore feature. Clicking a button to

  • 0

I have an app with a backup and restore feature. Clicking a button to backup will copy the db file to external storage. Clicking the restore button will take the file from the external storage (if it exists) and copy it into the app, overwriting the existing db with the backup db file.

I have encountered the issue when an update is performed on a table. After a table is updated with data, the database with updated data will not copy into the external storage, or if I try to restore after an update is made, the file is not copied.

When an item is saved, the db is opened, then the following function is called to perform the update, then the db is closed.

public void saveItem(int ItemID, int ItemNumber, String itemnote) 

{

        ContentValues args = new ContentValues();
        args.put("ItemNote", itemnote);
    mDb.update("Items", args, "ItemID =" + Item+" and ItemNumber ="+ItemNumber, null);

}

After the update occurs, what is preventing the db file from being copied?

I am using the following code to import the db backup into the app. Again, this all works prior to the update statement being executed. Thanks in advance.

importdb.setOnClickListener(new View.OnClickListener(){
public void onClick(View arg0) {

            final File DATA_DIRECTORY_DATABASE = getDatabasePath("MyDB");

            final File DATABASE_DIRECTORY = new File(Environment.getExternalStorageDirectory(),"/MyApp");
            final File IMPORT_FILE = new File(DATABASE_DIRECTORY,"MyDB");

            File exportFile = DATA_DIRECTORY_DATABASE;

            File importFile = IMPORT_FILE;


            try {
                exportFile.createNewFile();
                copyFile(importFile, exportFile);
                Log.i("Import", "Succesfull");

            } catch (IOException e) {
                e.printStackTrace();

            }       




        }

    });

private static void copyFile(File src, File dst) throws IOException {
    FileChannel inChannel = new FileInputStream(src).getChannel();
    FileChannel outChannel = new FileOutputStream(dst).getChannel();
    try {
        inChannel.transferTo(0, inChannel.size(), outChannel);
    } finally {
        if (inChannel != null)
            inChannel.close();
        if (outChannel != null)
            outChannel.close();
    }
}
  • 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-17T23:19:48+00:00Added an answer on June 17, 2026 at 11:19 pm

    After doing much testing on different devices and reviewing log files. It was discovered that on some devices the database is in write ahead logging mode (wal). This is not all devices, but on one of my test devices HTC Droid Incredible, wal is enabled, where as on the kindle fire wal is not enabled.

    On the devices where wal is not enabled, there is no issue. On the devices with wal, the import and export of data was not working because the actual db file wasn’t current, as any changes reside in the wal file and do not get committed to the db file until a checkpoint for wal is hit.

    To make sure the import and export functions are working properly, I need the db to contain the most up to date information. To accomplish this, a sqlite statement needs to be run to execute a wal checkpoint which will commit all information to the db file.

    Before the export or import functions are run, the following sqlite command is executed to initiate a checkpoint and clear out the wal and commit the changes to the database.

    PRAGMA wal_checkpoint

    After the checkpoint is called the functions are working properly

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

Sidebar

Related Questions

I have an app, that uses backup feature. This is line from my manifest:
I'd like to have a 'backup' and 'restore' button in my app that just
I need to have some mechanism to backup and restore some data files from
I have a requirement to enable/disable file sharing from with in the App. My
I'm developing an android app that backup the playlists from my device then restore
I have .net app in which there is function for Database backup and restore.
We have App A as main app. Now we build from it App B
I am developing a backup/restore system for my app in which the user can
I have an app which saves backup files on SD-Card. It works fine on
I have datastore admin enabled in one app and the backup system seems 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.