Android Question How to Add SQLite to Assets

evbedp

Member
Licensed User
Longtime User
Can i add sqlite database to assets?
im use database for read only, i will never insert,update or delete it. just use for select data.

schema and record will make out of application.
 

evbedp

Member
Licensed User
Longtime User
finally i found the menu for add file to assets, but sqlite still can't read in assets directory.
but that's ok, because i can copy it first to internalcache. sqlite in asset can use for backup if file in cache lost.

Menu for add file to asset.
Tab page (Right Side Source Code Board) -> Files Manager -> Add Files

thank you.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
but sqlite still can't read in assets directory.
You cannot read a SQLite database located in Assets folder. It is always that way (it was that way in the past, now and in the immediate future). You can only read sequential files like a text file from assets, but SQLite database is a binary file. It can only be read if copied to internal or external folders.
 
Upvote 0

RichardN

Well-Known Member
Licensed User
Longtime User
I may be wrong but doesn't SQLite require both read and write accces to create/manipulate the journal file in the host directory? FileDirAssets does not allow this.
 
Upvote 0

evbedp

Member
Licensed User
Longtime User
we can save it in directory asset first. when we want use it. we should copy it to internal/external sd card first. after copy finish you can access database in internal/external sdcard, not in directory asset.
 
Upvote 0

evbedp

Member
Licensed User
Longtime User
I may be wrong but doesn't SQLite require both read and write accces to create/manipulate the journal file in the host directory? FileDirAssets does not allow this.

we can't access direct to sqlite if the file in directory assets, but if you copy it to internal/external sdcard. that's posibble to access (Read/Write). sqlite in directory asset can use for backup schema or general record. when you lost sqlite in internal / external, you can recover it from directory asset.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…