Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Android SQLite.

Options
  • 11-03-2013 2:35pm
    #1
    Registered Users Posts: 3,515 ✭✭✭


    Hey, I am making an android app and this is first time I am required to use and learn SQLite.
    I was following some crap tutorial which lead me nowhere and I ended up having this file:
    package com.example.droid;

    import android.content.Context;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteDatabase.CursorFactory;
    import android.database.sqlite.SQLiteOpenHelper;
    import android.util.Log;

    public class SqDb extends SQLiteOpenHelper{
    private static final String NAME = SqDb.class.getSimpleName();

    public static final String dName = "ExpenseR.db";
    public static final int dVer = 1;
    public static final String table = "Expenses";
    public static final String sql = "create table user_data (" +
    "_id INT PRIMARY KEY AUTOINCREMENT, " +
    "_typ VARCHAR(20)," +
    "_desc VARCHAR(255)," +
    "_day INT(2)," +
    "_mon INT(2)," +
    "_cat VARCHAR(25)," +
    "_val REAL," +
    "_time TIMESTAMP);";

    public SqDb(Context context) {
    super(context, dName, null, dVer);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
    db.execSQL(sql);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }

    }

    How do I add/read entries from db from other classes.


Advertisement