Search code examples
androidsqlitenotepad

Storage of SQLite database in Android Notepad tutorial


I am a beginner of Android programming and working my way through the Notepad tutorial now. I am puzzled by where the SQLite database is stored. I don't see an explicit statement of saving the database somewhere on the drive, then how the application manage to open this database when the app is restated. To be more specific, how DbHelper.open() knows which database to load. If there are two DbHelper member field in one app and each of these manages one database, then how they manage to open the correct one next time the app is opened? Thank you!


Solution

  • /data/data/yourpackage.name/databases. this is the place where your database is stored.. and for the question how dbhelper will know which database to open.. you will have this function in your dbhelper(which extends SQLiteOpenHelper) class..

     @Override
    public void onCreate(SQLiteDatabase database) {
        database.execSQL(DATABASE_CREATE);
    
    }
    

    which creates a table in the given database... so each dbhelper opens that particular database which was created in this function..