1

I am creating an android application using Eclipse. I want to ask on how to create a database using SQLite. The database will only have 3 tables which is user_id, user_name, and user_password.

2 Answers 2

1
  1. Formulate CREATE statements for your tables.
  2. (a) on desktop create a SQLite db and then push the directory to emulator. Use SQLite command line to execute these statements, or

    (b) connect to android shell then you will get SQLite shell. or

    (c) in your android activity, fire SQL command (as mentioned by user522751 )

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the reply, it really did help me in understanding SQLite. However, I researched some informations on how to create database and I found out that there is a SQLite Database Browser. I am wondering if how could I import the created database into Eclipse IDE.
what do u mean by importing db into Eclipse IDE?
0

You can try SQLiteOpenHelper, here is what i did in a demo app few weeks ago.. import static com.kevin.fastcard.utils.ColumnConstants.; import static com.kevin.fastcard.utils.DBConstants.;

public class DBHelper extends SQLiteOpenHelper { public DBHelper(Context context) { super(context, DB_NAME, null, DB_VERSION); }

@Override
public void onCreate(SQLiteDatabase db) {
    // TODO Auto-generated method stub
    db.execSQL("CREATE TABLE " + TBL_NAME + "(" + _ID
            + " INTEGER PRIMARY KEY AUTOINCREMENT," + QUESTION + " TEXT,"
            + ANSWER + " TEXT," + CATEGORY + " TEXT," + CREATE_TIME
            + " TEXT," +TIME_IN_MILLIS+" INTEGER"+ ");");
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    // TODO Auto-generated method stub
    db.delete(TBL_NAME, null, null);
}

}

I'm new to android, hope that can help you..

1 Comment

thanks for the reply, I'm also a newbie in android. Have you tried using the SQLite Database Browser?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.