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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:27:17+00:00 2026-05-27T05:27:17+00:00

we all know the android system database should be stored in /data/data/package name/ directory,there

  • 0

we all know the android system database should be stored in /data/data/package name/ directory,there is a existing database i want to use in my application.

some people might tell me just put the orginal database in the /res/raw/ directory,and then use FileInputStream to read it, read into things FileOutStream to write to that directory. that’s a good idea,

But the problem is that not all of the phones have root access for you to access the system directory, And also i can’t just put the db file in the sdcard and read data from there,because you didn’t know if there is a sdcard in the phone either. I really have no idea for this, Did anyone can give me a hand? i appreciate for that.

  • 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-27T05:27:18+00:00Added an answer on May 27, 2026 at 5:27 am

    I have an 80 megabyte SQLite database that I converted from Microsoft Access 10. I download it to 1) the phone’s sdcard, 2) sdcard-ext, or 3) internal storage depending on available space. The SQLite database was created on a PC using SQLite 3.7.4. It runs fine on Androids from version 2.2 (8) and up. For processing I created a DatabaseAdapter class that does not use open helper.

    Here’s the database open from my DatabaseAdapter class:

    public DatabaseAdapter open() {
        MyLog.d(TAG, "open");
        try {
            String databaseFile = databasePath + File.separator
                    + GC.DATABASE_NAME;
            theDB = SQLiteDatabase.openDatabase(databaseFile, null,
                    SQLiteDatabase.OPEN_READONLY
                            | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
        } catch (SQLiteException e) {
            MyLog.d(TAG, "open error: " + e.getMessage());
            theDB = null;
        }
        if (theDB == null) {
            return null;
        }
        return this;
    }
    

    The constructor passes the path. The sequence of use is

        DatabaseAdapter dbAdapter = new DatabaseAdapter(databasePath);
    
        if (dbAdapter.open() == null) {
            // ooops. no database open...
            return;
        }
    
        Cursor cursor = dbAdapter.someQuery(arg1, where, limit);
        if (cursor != null)
            while (cursor.moveToNext()) {
               field1 = cursor.getString(0);
               // etc.
            }
            cursor.close();
        }
    
        dbAdapter.close();
    

    The key to the external database open is the NO_LOCALIZED_COLLATORS flag. Without it, the open will try to access the Android created localization table. When creating external databases, the table isn’t created and, when run on a phone, a table not found blow up occurs.

    To determine the path you want to use for the database, use Environment.getExternalStorageState() and use the sdcard or internal storage accordingly.

    Use getExternalStorageDirectory() to get the sdcard directory. Use this.getApplicationContext().getFilesDir()
    .getPath() to get the internal storage path. Assuming that you if’d the local or external path into databasePath, you can download the database into an output file created as

    File downloadOutput = new File(databasePath, “mysqlite.db”);

    After it is downloaded, you can use the open() illustrated above to ready your database for access. (Note: the database can be opened as writable, not just read only as shown.)

    Hope I didn’t over explain…

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

Sidebar

Related Questions

I know that Android is an open source system, so all the code should
First of all I know it's bad to use a task manager/killer in Android
For understanding how strong data should be secured on an Android device I want
As we all know, how to use google map with system/framework/map.jar with user-library .
We all know how to use <ctrl>-R to reverse search through history, but did
The call to System.currentTimeMillis() returns always 0 on Motorola Droid, Android 2.0. There is
I know you can use python and other scripting languages in android. But I
I know Android is open source, but are all the apps that they make
in my app i use Using an existing sqlite database and i need to
I am using aws-android-sdk and on DroidX all was fine. But after last system

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.