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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:27:41+00:00 2026-06-08T18:27:41+00:00

My question is that I want to restore my application’s sqlite database after I

  • 0

My question is that I want to restore my application’s sqlite database after I overwrite the same app on my device. I don’t like to add settings again and again on start up of my app.

So is it possible in android to save the database somewhere from which I can again restore it ?

I have searched for more than hours on Google and SO but couldnt ind any solution.

EDIT: Its not a fixed database. So I can’t store it in Assets Folder. It is editable by user but by default it should carry the last edited values(values before the app overwrite).

  • 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-08T18:27:42+00:00Added an answer on June 8, 2026 at 6:27 pm

    This method I find very helpful:

    public static void movedb(File srcdb, File destdb)
    {
        try 
        {
            if (Environment.getExternalStorageDirectory().canWrite()) 
            {                 
                if (srcdb.exists()) 
                {
                    FileChannel src = new FileInputStream(srcdb).getChannel();
                    FileChannel dst = new FileOutputStream(destdb).getChannel();
                    dst.transferFrom(src, 0, src.size());
                    src.close();
                    dst.close();                    
                }
                else
                {
                    //ERROR: "Database file references are incorrect"                    
                }
            }
            else
            {
                //ERROR: "Cannot write to file"
            }
        }
        catch (Exception e) 
        {
            //ERROR: e.getMessage()
        }
    }
    

    Then I just call

    movedb(this, new File(<context>.getDatabasePath("...your DB name...")), new File("... your location ..."));
    

    To back up, and then to restore:

    movedb(this, new File("... your location ..."), new File(<context>.getDatabasePath("...your DB name...")));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is another question that I want to know that how to apply any
The method in question that I want to use is gem and sourced here
I have a slightly theoretical question that I want to clear up before I
hey, my question is that i want to display the names whose payment type
I want to ask a basic question that I couldn't find in online tutorials.
Hello every one I want to ask a question that what is simple exec
My question is about a specific array operation that I want to express using
This question is sort of a sequel to that question. When we want to
Potentially embarrassing question, but there is obviously something I'm missing that I want/need to
I have a simple question. I have a long std::string that I want 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.