So Tim Holloway, you were right.
I have resolved this issue through my own experimenting and happening on
this stackoverflow post.
App Specific Internal Storage
Every app has a data directory, :/data/app_package/ which is private to it only. The path to this is obtained by calling getDataDir() on the app's context object, i.e context.getDataDir(). The docs for android class Context say that the data directory should not be used directlyA sub-directory of the data directory is the files directory (:/data/app_package/files/) obtained by context.getFilesDir(). Official android docs/guides say this where files private should be storedDatabase files are stored in subdirectory :/data/app_package/databases. This is where SQLiteOpenHelper. getWritableDatabase() expects to find them. However, creating a subdirectory :data/app_package/databases/ programmatically fails and throws an IOException
My Solution
After reading docs for android class Context (the context is like the "environment" e.g. storage, device, memory, wifi etc within which the app is created:
Method context.getDatabasePath(String name) abstracts the creation of the databases directory and the database file of the specified name within that directory The AssetCopier, class I defined in my experiments (see below) , therefore copies the database from assets folder into the above locationThe log message (equivalent to System.out.println) confirms that the db file is copied and returns its file path.
Then in the main acitivity - which I use just as a starting point.
Logcat output:
2022-08-30 15:03:55.065 15697-15697/com.mo.copydbfromassets E/De-bug Message :: File copied.
2022-08-30 15:03:55.065 15697-15697/com.mo.copydbfromassets E/De-bug Message :: the path to the file is :/data/user/0/com.mo.copydbfromassets/databases/testDB.db