Android Question How to Add SQLite to Assets

Discussion in 'Android Questions' started by evbedp, Feb 9, 2019.

  1. evbedp

    evbedp Member Licensed 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.
     
  2. evbedp

    evbedp Member Licensed 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.
     
  3. Mahares

    Mahares Well Known Member Licensed User

    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.
     
    jimmyF likes this.
  4. RichardN

    RichardN Active Member Licensed 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.
     
  5. evbedp

    evbedp Member Licensed 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.
     
  6. evbedp

    evbedp Member Licensed User

    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.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice