mercredi 24 février 2016

Android Studio SQLite database

I am working on a project in Android Studio. I want to insert data into SQLite Database from a.txt file in app first run, I have this file in res/drawable/a.txt .

In a.txt file are rows like:

1 Bread 41,0 0,8 0,2 11,8

2 IceCream 400,0 14,5 6,5 66,2

3 Cake 54,0 0,4 0,2 13,

and 100 more products

my created table:

public void onCreate(SQLiteDatabase db) {

    db.execSQL("create table " + TABLE_NAME + "(ID INTEGER PRIMARY KEY AUTOINCREMENT,Name VARCHAR(20),Kcal FLOAT,PROTEIN FLOAT,FAT FLOAT,CARBOHYDRATES FLOAT)");}

THANKS FOR HELP :)

Aucun commentaire:

Enregistrer un commentaire