Sqlite create database and table with BAT file for Android

Sqlite3 create database and table with load.bat file and fill data to table example.

  1. Create folder for your project: my_sqlite_project
  2. Open folder and create file load.bat and paste to load.bat this text and save to project folder:
     
    sqlite3 my_database.s3db < load_text.sql
    pause
  3. Create load_text.sql file and paste this text and save to project folder:
    CREATE TABLE [android_metadata] (
    [locale] TEXT
    );
     
     
     
     
    CREATE TABLE [my_table] (
    [_id] int NULL,
    [word] VARCHAR(255)  NULL,
    [description] VARCHAR(255)  NULL
     
     
     
     
    .separator ";"
    .import text_file.txt my_table
  4. Create text_file.txt and paste this text and save it as UTF-8:
    1;word1;my first word
    2;word2; my second word
  5. Download sqlite3.exe and put to project folder.
  6. Run BAT file load.bat and read text instruction from console
  7. If database created you can open and edit this with sqlite database explorer
  8. Copy database to Asses Android project folder
  9. If you want using this database in Android application on device, you have to copy this database to folder on device /data/data/com.MyPackage/databases/
This entry was posted in SQLite database and tagged , , , , , . Bookmark the permalink.


Comments are closed.



5,274 views