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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:14:22+00:00 2026-06-02T15:14:22+00:00

I had created database in my android app, then inserted a statement. Everything worked,

  • 0

I had created database in my android app, then inserted a statement. Everything worked, so i wanted to get my database fro MY_PACKAGE/databses/ and copy it to sd card to be reachable.

This worked, but when i trying to open with my sqlite Firefox plugin i get this error:

SQLiteManager: Error in opening file Datas.sqlite - either the file is encrypted or corrupt
Exception Name: NS_ERROR_FILE_CORRUPTED
Exception Message: Component returned failure code: 0x8052000b (NS_ERROR_FILE_CORRUPTED) [mozIStorageService.openUnsharedDatabase] 

Maybe i have to open with something else or i can’t open this so easily ?

I will give all the code i used:

Handling my db i used all this code:

Using your own SQLite database in Android applications

Copying it to sd card this method:

public static boolean backUpDataBase(Context context) {

        final String DATABASE_NAME = "Data.sqlite";
        final String DATABASE_NAME_FULL = "/data/data/package/databases/"
                + DATABASE_NAME;
        boolean result = true;

        // Source path in the application database folder
        String appDbPath = DATABASE_NAME_FULL;

        // Destination Path to the sdcard app folder
        String sdFolder = Environment.getExternalStorageDirectory()
                .getAbsolutePath() + "/" + "Datas.sqlite";

        File f = new File(sdFolder);
        // if (!f.exists()) {
        // f.mkdir();
        // }

        InputStream myInput = null;
        OutputStream myOutput = null;
        try {
            // Open your local db as the input stream
            myInput = new FileInputStream(appDbPath);
            // Open the empty db as the output stream
            myOutput = new FileOutputStream(f);

            // transfer bytes from the inputfile to the outputfile
            byte[] buffer = new byte[1024];
            int length;
            while ((length = myInput.read(buffer)) > 0) {
                myOutput.write(buffer, 0, length);
            }
        } catch (IOException e) {
            result = false;
            e.printStackTrace();
        } finally {
            try {
                // Close the streams
                if (myOutput != null) {
                    myOutput.flush();
                    myOutput.close();
                }
                if (myInput != null) {
                    myInput.close();
                }
            } catch (IOException e) {
            }
        }

        return result;
    }

My database looks like this:
2 tables:

CREATE TABLE "Test" ("_id" INTEGER PRIMARY KEY  NOT NULL  UNIQUE , "Info" TEXT)

CREATE TABLE "android_metadata" ("locale" TEXT DEFAULT 'en_US')

And code to do all i need:

//return databse which is read and write
DataBaseHelper dataBase= Main.createOrOpenDB(mContext);

        Main.backUpDataBase(mContext);

        db = dataBase.myDataBase;

        // Step 1: Inflate layout
        setContentView(R.layout.tabs_fragment_activity);

        try{
        db.execSQL("INSERT INTO " +"Test" +" Values ('1','Inserted');");
        }catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }

So where is wrong, as insert works fine?

  • 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-02T15:14:23+00:00Added an answer on June 2, 2026 at 3:14 pm

    It sounds like there is a problem in your code to write it to the SD card (which I’m not seeing immediately).

    I wonder, why are you copying it to the SDCard? It sounds like you merely want to check the file…

    If that’s actually your goal, then I would recommend running the emulator and simply using the DDMS view from eclipse, navigate to the file and click the button in the upper right corner whose tool-tip says “Pull a file from the device”. What you get in the emulator should be exactly what you get on your phone.

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

Sidebar

Related Questions

I had developed an app in android that take some data from a database
I initially created an SQLite database on Windows and then had problems accessing it
In one of my builds for an iPhone app, I had inadvertently created a
I had created an ASP.NET web app using: ASP.NET MVC 3 Webforms Linq to
I had created a MDF database file and I just recently reformatted my computer.
I have a question about the databases in Android. I had created in my
I am creating an app that needs a database. I created it using sqlite
i am new user of android and i had make one android database connection
I created a database in SQL locally on my phone for an app and
I had created one HTML page for my experiance. In this i had use

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.