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

  • Home
  • SEARCH
  • 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 6230239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:42:37+00:00 2026-05-24T09:42:37+00:00

I have to set up 2 database for one application. I did & working

  • 0

I have to set up 2 database for one application. I did & working fine in the emulator.Emulator minSDKVersion is : 8 real phone version is :2.2.1. It support. When I setup the database in real phone I couldn’t set up. Always I am getting unable create DB.I think one is rooted one, because when I go to File explore -> data. I couldn’t open data folder.

I have doubt in apk, because My application size is 8 MB.It contain database in asset folder. That size is 4.65 MB. But apk file size is 1.14MB.

How it will read from asset folder(In the real phone)?

I really don’t know whether it is wrong or right..These are my doubt.Please explain me.

I got error this :

enter image description here
Please help me.

Is there any mistake my coding part or other than anything?

Please help me.

Thanks in advance….

Edited

This is my code for copyDatabase:

public class DataBaseMasterHelper extends SQLiteOpenHelper {

// The Android's default system path of your application database.
private static String DB_PATH = "/data/data/com.android.xont.controller/databases/";
private static String DB_NAME = "MasterUserVentura_HEMA.db";
private SQLiteDatabase ventura;
private  Context myContext;
private DataBaseHelper myDbHelper;

public DataBaseMasterHelper(Context context) {
    super(context, DB_NAME, null, 1);
    this.myContext = context;
}

/**
 * Creates a empty database on the system and rewrites it with your own
 * database.
 **/
public void createDataBase() throws IOException {

    boolean dbExist = checkDataBase();
    File Path = myContext.getDir("Data", 0);
    File DBFile = new File(Path, DB_NAME);
    System.out.println("-------" + DB_NAME);
    if(!DBFile.exists())  //Need to copy...
        copyDataBase(myContext, DBFile);

}

public boolean checkDataBase() {
    SQLiteDatabase checkDB = null;
    try {
        String myPath = DB_PATH + DB_NAME;
        checkDB = SQLiteDatabase.openDatabase(myPath, null,SQLiteDatabase.OPEN_READONLY);
    } catch (SQLiteException e) {
        e.printStackTrace();
    }

    if (checkDB != null) {
        checkDB.close();
    }

    return checkDB != null ? true : false;
}

private void copyDataBase(Context Ctxt, File DBFile) throws IOException {
    InputStream myInput = myContext.getAssets().open(DB_NAME);
    String outFileName = DB_PATH + DB_NAME;
    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();


}

public void openDataBase() throws SQLException {
    String myPath = DB_PATH + DB_NAME;
    ventura = SQLiteDatabase.openDatabase(myPath, null,
            SQLiteDatabase.OPEN_READONLY);

}

@Override
public synchronized void close() {
    if (ventura != null)
        super.close();
        ventura.close();
}

and calling like this:

  MyGrid.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView parent, View v, int position,long id) {
            
            if (position == 0) {
                try {
                    myDbMasterHelper.createDataBase();
                    Toast.makeText(DatabaseSetupActivity.this, "Successfully copied database",Toast.LENGTH_SHORT).show();
                } catch (IOException ioe) {
                    Toast.makeText(DatabaseSetupActivity.this, "Unable to create database",Toast.LENGTH_SHORT).show();
                    ioe.printStackTrace();
                }catch (Exception ioe) {
                    Toast.makeText(DatabaseSetupActivity.this, "Unable to create database",Toast.LENGTH_SHORT).show();
                    ioe.printStackTrace();
                }
                
                
            }else if (position == 1) {
                try {
                    myDbHelper.createDataBase();
                    Toast.makeText(DatabaseSetupActivity.this, "Successfully copied database",Toast.LENGTH_SHORT).show();
                } catch (IOException ioe) {
                    Toast.makeText(DatabaseSetupActivity.this, "Unable to create database",Toast.LENGTH_SHORT).show();
                    ioe.printStackTrace();
                
                }catch (Exception ioe) {
                    Toast.makeText(DatabaseSetupActivity.this, "Unable to create database",Toast.LENGTH_SHORT).show();
                    ioe.printStackTrace();
                }
                
                

            }
        }
    });

working fine the emulator. If the file size problem, then should have get error in emulator also?

I got error like this:

 java.io.FileNotFoundException: /data/data/com.android.xont.controller/databases /MasterUserVentura_HEMA.db (No such file or directory)

I have changed e.printStackTrace() instead of throw expecption.

I think,This is not file size problem.because I did same thing in small size 300kb(testng2.db).That one also giving same error

My real phone is HTC HD2 its Windows Mobile® 6.5 Professional.

Please help me.

Thanks in advance…

  • 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-05-24T09:42:38+00:00Added an answer on May 24, 2026 at 9:42 am

    The problem is you cannot read the data from the asset folder. Make sure the DB_NAME has form
    "mydatabase.db" (including the extension). Try using lower cases, it might be case sensitive.

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

Sidebar

Related Questions

I'm working on my first android app and have an SQLite database set up
I have one application which uses NHibernate to save entities to a database, and
Suppose the following: I have a database set up on database.mywebsite.com , which resolves
Ok, here is my dilemma I have a database set up with about 5
I have a mysql database set as utf-8, and csv data set as utf-8,
I have a legacy database set with NLS_LANG set to IW8ISO8859P8. This I cannot
If you have a set of tables in the database that strictly consist of
Say I have an ID row (int) in a database set as the primary
In a database prototype, I have a set of fields (like name, description, status)
I have a system set up to lock certain content in a database table

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.