Skip to content

Instantly share code, notes, and snippets.

@nikhilbansal97
Created August 8, 2017 13:03
Show Gist options
  • Save nikhilbansal97/a266688969aeefe22593b7028bdb75df to your computer and use it in GitHub Desktop.
Save nikhilbansal97/a266688969aeefe22593b7028bdb75df to your computer and use it in GitHub Desktop.
package com.example.nikhil.simpledatabase.database;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DataHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "data.db";
public static final int DATABASE_VERSION = 1;
public DataHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
String CREATE_TABLE_QYERY = "CREATE TABLE " + DataContract.DataProvider.TABLE_NAME + "( " +
DataContract.DataProvider.COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
DataContract.DataProvider.COLUMN_DATA_ITEM + " TEXT NOT NULL);";
sqLiteDatabase.execSQL(CREATE_TABLE_QYERY);
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment