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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:25:43+00:00 2026-06-04T10:25:43+00:00

Im new to android development. Now im trying to use sqlite db. I created

  • 0

Im new to android development. Now im trying to use sqlite db. I created a database sqlite file using sqlite manager.
I have tried the following code, it works fine in emulator , but if I took release in device the app crashes ie,it shows an alert message The application CheckMobileForDatabase has stopped unexpectedly, my sdk version is 2.2(8)

 private void StoreDatabase() {
 File DbFile=new File("data/data/com.sqldemo/databases/idua1");
 if(DbFile.exists())
 {
     System.out.println("file already exist ,No need to Create");
 }
 else
 {
     try 
     {
         DbFile.createNewFile();
         System.out.println("File Created successfully");
         InputStream is = this.getAssets().open("idua1.sqlite");
         FileOutputStream fos = new FileOutputStream(DbFile);
         byte[] buffer = new byte[1024];
            int length=0;
            while ((length = is.read(buffer))>0)
            {
            fos.write(buffer, 0, length);
            }
         System.out.println("File succesfully placed on sdcard");
            //Close the streams
            fos.flush();
            fos.close();
            is.close();
     }
     catch (IOException e)
     {
         e.printStackTrace();
     }
   }    
   }
  • 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-04T10:25:44+00:00Added an answer on June 4, 2026 at 10:25 am

    Without your logcat, this is just shooting in the dark.

    You could try checking the existence of the file another way:

    private static boolean checkDataBase(String dbname) {
        SQLiteDatabase checkDB = null;
        boolean exist = false;
        try {
            String db = MAIN_DB_PATH + dbname;
            checkDB = SQLiteDatabase.openDatabase(db, null,
                    SQLiteDatabase.OPEN_READONLY);
        } catch (SQLiteException e) {
            Log.v("db log", "database does't exist");
        }
        if (checkDB != null) {
            exist = true;
            checkDB.close();
        }
        return exist;
    }
    

    And then run another method to copy the db if it doesn’t exist:

    private static void copyDataBase(String dbname) throws IOException {
        InputStream myInput = mCtx.getAssets().open(dbname);
        String outFileName = MAIN_DB_PATH + dbname;
        OutputStream myOutput = new FileOutputStream(outFileName);
        byte[] buffer = new byte[1024];
        int length;
        while ((length = myInput.read(buffer)) > 0) {
            myOutput.write(buffer, 0, length);
        }
        myOutput.flush();
        myOutput.close();
        myInput.close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im new to android development. Now im trying to use sqlite db. I created
friends I am new to iphone development, I have mostly worked with Android, now
I am very new to android development.... i have created an app and want
I am new to Java / Android development, and I am now trying to
I am new to android. I using emulator for my development right now ,
I'm new to both android and game development and have been trying to create
I'm new to Android development, i'm trying to port an IOS app to Android.
I am new to android development and I've hit a hurdle when trying to
I am new to Android development and facing a problem while using AndEngine. I
I'm brand new to Android development and right now I am building a simple

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.