daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Jun 7th, 2017 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class RegistrationDB extends SQLiteOpenHelper {
  2.  
  3.     private static final int DATABASE_VERSION = 1;
  4.     private static final String DATABASE_NAME = "registration.db";
  5.     private static final String TABLE_NAME = "profile";
  6.     private static final String COLUMN_ID = "id";
  7.     private static final String COLUMN_EMAIL = "email";
  8.     private static final String COLUMN_USERNAME = "username";
  9.     private static final String COLUMN_PASSWORD = "password";
  10.  
  11.  
  12.     private static final String CREATE_TABLE =
  13.             "CREATE TABLE " + TABLE_NAME + " (" +
  14.                     COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
  15.                     COLUMN_USERNAME + " TEXT, "+
  16.                     COLUMN_EMAIL + " TEXT, " +
  17.                     COLUMN_PASSWORD + " TEXT, " + ")";
  18.  
  19.     private String DROP_TAPLE = "DROP TABLE IF EXISTS " + TABLE_NAME;
  20.  
  21.     public RegistrationDB(Context context) {
  22.         super(context, DATABASE_NAME, null, DATABASE_VERSION);
  23.  
  24.     }
  25.  
  26.  
  27.     @Override
  28.     public void onCreate(SQLiteDatabase sqLiteDatabase) {
  29.         sqLiteDatabase.execSQL(CREATE_TABLE);
  30.  
  31.     }
  32.  
  33.     @Override
  34.     public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
  35.         sqLiteDatabase.execSQL(DROP_TAPLE);
  36.         onCreate(sqLiteDatabase);
  37.  
  38.     }
  39.  
  40.     public long addUser(String email, String username, String password) {
  41.         SQLiteDatabase db = this.getWritableDatabase();
  42.         ContentValues values = new ContentValues();
  43.  
  44.         values.put(COLUMN_EMAIL, email); // Email
  45.         values.put(COLUMN_USERNAME, username); // username
  46.         values.put(COLUMN_PASSWORD, password); // password
  47.  
  48.         // Inserting Row
  49. //        long id = db.insert(TABLE_NAME, null, values);
  50.         db.insert(TABLE_NAME, null, values);
  51.         db.close(); // Closing database connection
  52.         return 0;
  53.     }
  54.  
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top