简单的sqlite例子?

Not*_*oid -1 sqlite android

可能重复:
android中的sqlite示例程序

嗨,我是Android的新手,我在查找SQLite数据库的好教程时遇到了一些麻烦.我想要做的是在数据库中存储一行数据,稍后引用它,然后在引用它之后将其删除.正如我所说的,我对这种事情不熟悉,甚至连任何语法都没有任何线索,如果有一个简单的教程,我想知道.

vis*_*sta 6

试试这个

try { // creating a database called db and a Table inside it, called
            // userdetails. With username and password as columns.

        db = openOrCreateDatabase("UserDetails.db",
                Context.MODE_PRIVATE, null); // optional CursorFactory
        db.execSQL("drop table if exists userdetails");
        db.execSQL("create table userdetails " + " ( username TEXT,"
                + "password TEXT);");

    } catch (SQLException x) {
        x.printStackTrace();
        Log.e(LOG_TAG_NAME, "Database creation error");

    }

//.........................................................................
    // and insert values into the database table.
    try {
        db.execSQL("INSERT INTO " + "userdetails"
                + " (username,password)" + " VALUES ('hi','hello');");
        db.execSQL("INSERT INTO " + "userdetails"
                + " (username,password)" + " VALUES ('chris','gayle');");
        db.execSQL("INSERT INTO " + "userdetails"
                + " (username,password)" + " VALUES ('v','v');");
    } catch (Exception e) {
        e.printStackTrace();
        Log.e(LOG_TAG_NAME, "inserting table values error");
    }
    String[] columns = { "username", "password" };
    Cursor c = db.query("userdetails", columns, null, null, null, null,
            null);
Run Code Online (Sandbox Code Playgroud)

现在使用光标来检索值

还看看

http://developer.android.com/guide/topics/data/data-storage.html#db

希望这一切都有帮助