Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code> public class Database { private static final String TAG = "DbAdapter"; private DatabaseHelper mDbHelper; private SQLiteDatabase mDb; public static final String TABLE_COMMENTS = "tablename"; public static final String COLUMN_ID = "_id"; public static final String COLUMN_COMMENT = "comment"; private static final String DATABASE_NAME = "databasename"; private static final int DATABASE_VERSION = 1; private final Context mCtx; private static class DatabaseHelper extends SQLiteOpenHelper { // Database creation sql statement private static final String DATABASE_CREATE = "CREATE TABLE tablename (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , column1 INTEGER, column2 TEXT, column3 TEXT, column4 TEXT, column5 TEXT, column6 NUMERIC)"; public DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase database) { database.execSQL(DATABASE_CREATE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { Log.w(DatabaseHelper.class.getName(), "Upgrading database from version " + oldVersion + " to " + newVersion + ", which will destroy all old data"); db.execSQL("DROP TABLE IF EXISTS " + TABLE_COMMENTS); onCreate(db); } } public Database(Context c) { this.mCtx = c; } public void open() throws SQLException { mDbHelper = new DatabaseHelper(mCtx); mDb = mDbHelper.getWritableDatabase(); } public void close() { mDbHelper.close(); } public void inset(ContentValues cv) { mDb.insert(TABLE_COMMENTS, null, cv); } public Cursor getdata() { Cursor c = mDb.rawQuery("SELECT * FROM tablename", null); return c; } public Cursor getById(int index) { Cursor c = mDb.rawQuery("SELECT * FROM tablename where field ="+index, null); return c; } public void deletedata(int index) { mDb.rawQuery("delete from tablename where id ="+index, null); } public boolean checkRegistration(String name) { Cursor c = mDb.rawQuery("SELECT * FROM tablename where column name= "+name, null); int count = c.getCount; c.close(); if(count &gt; 0) { return false; } else { return true; } } } Database db =new Database(this); db.open(); if(db.checkRegistration(str)) { //please register this user. } else { //this user already register } db.close(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload