How to insert data into the database file which is in the assets folder

前端 未结 3 904
不思量自难忘°
不思量自难忘° 2020-12-18 13:30

I have created a SQLite file and putted it on to assets folder. Now I am able to read the data from that file but I don\'t have any idea how to write to this database file.

3条回答
  •  悲哀的现实
    2020-12-18 14:29

    As the /asset directory is read only (because android .apk file is read-only) so you can't write anything in asset folder file, you have to first copy that sqlite database file into your application's internal storage /data/data//databases directory then you can modify your database file..

    1. Copy your pre-populated sqlite database file into data/data//databases directory,

    2. Open that database file (from /databases/ directory) in your sqlite database helper class..

    3. Perform insert, update or select operation on that database..

提交回复
热议问题