Android Question Access read only db from File.DirAssets?

GEoffT

Member
Licensed User
Longtime User
I have shipped a read only db with my app. Can I access it directly from File.DirAssets or do I have to copy it having first deleted any existing one in FIle.DirDefaultExternal?
 

Star-Dust

Expert
Licensed User
Longtime User
File.DirAssets is only read.
When SQLite reads creates an index file, and then writes it to the folder. So you can not read a sql file directly on File.DirAssets because it is not allowed to create (or write) a file in the folder

But you can copy file.DirInternal if is file private.
Use File.DirInternalCache if the file is temporary.

You can copy it to File.DirRootExternal if you want other Apps to access this file as well.
Obviously if you copy it to File.DirRootExternal it would be better if you create a folder, it would be more orderly.


Do not use File.DirDefaultExternal because some devices may have problems
 
Last edited:
Upvote 0
Top