Android Open Source - GPA Db Helper






From Project

Back to project page GPA.

License

The source code is released under:

Apache License

If you think the Android project GPA listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.bishal.android.taskmanager;
//  w  w  w  . j a  v a2s  .c o  m
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DbHelper extends SQLiteOpenHelper{

  private static final String TAG=DbHelper.class.getSimpleName();
  public static final String DB_NAME="Store Account.db";
  public static final int DB_VERSION=1;
  public static final String TABLE="Account_Info";
  public static final String COL_ID="Id";   //special for ID
  public static final String COL_NAME="Name";
  public static final String COL_EMAIL="Email";
  //public static final String COL_UNAME="Username";
  public static final String COL_PASSWORD="Password";
  
  public DbHelper(Context context) {
    super(context, DB_NAME, null, DB_VERSION);
    
  }

  @Override
  public void onCreate(SQLiteDatabase db) {
    // TODO Auto-generated method stub
    
        String CREATE_ACCOUNT_INFORMATION = "CREATE TABLE " + TABLE + "("
        + COL_ID + " INTEGER PRIMARY KEY," + COL_NAME + " String,"
         + COL_EMAIL + " String," + COL_PASSWORD + " String" + ")";
    
    Log.d(TAG, "onCreate sql: "+CREATE_ACCOUNT_INFORMATION);
    db.execSQL(CREATE_ACCOUNT_INFORMATION);
    
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    // TODO Auto-generated method stub
    db.execSQL("Drop Table If Exists " + TABLE);
    Log.d(TAG,"onUpdate dropped table "+ TABLE);
    onCreate(db);
  }
  
  
  void addAccount(ACCOUNT_INFO account){
    SQLiteDatabase db=this.getWritableDatabase();
    ContentValues values=new ContentValues();
    values.put(COL_NAME,account.getNAME());
    values.put(COL_EMAIL,account.getEMAIL());
    //values.put(COL_UNAME, account.getUSERNAME());
    values.put(COL_PASSWORD, account.getPASSWORD());
    db.insert(TABLE, null, values);
    db.close();
  }
  
  
  
  public boolean validateuser(String email,String password){
    Cursor c=getReadableDatabase().rawQuery("SELECT * FROM " + TABLE + " WHERE "
                + COL_EMAIL + "='" + email +"'AND "+COL_PASSWORD+"='" + password+"'" ,  null);
    if(c.getCount()>0)
      return true;
    else
    return false;
  }
  
  public boolean validateregister(String email){
    Cursor c=getReadableDatabase().rawQuery("SELECT * FROM " + TABLE + " WHERE "
                +  COL_EMAIL + "='" + email +"'" ,  null);
    if(c.getCount()>0)
      return false;
    else
    return true;
  }
}




Java Source Code List

com.bishal.android.taskmanager.ACCOUNT_INFO.java
com.bishal.android.taskmanager.ADD_TASK.java
com.bishal.android.taskmanager.AddLocationMapActivity.java
com.bishal.android.taskmanager.AddTaskActivity.java
com.bishal.android.taskmanager.AlarmActivity.java
com.bishal.android.taskmanager.AlertDialogManager.java
com.bishal.android.taskmanager.AndroidAlarmService.java
com.bishal.android.taskmanager.CURRENT_LOCATION.java
com.bishal.android.taskmanager.DB_ADAPTER.java
com.bishal.android.taskmanager.DbHelper.java
com.bishal.android.taskmanager.GPA_HOME.java
com.bishal.android.taskmanager.GPS_FIELD.java
com.bishal.android.taskmanager.GPS_INFO.java
com.bishal.android.taskmanager.LOGIN.java
com.bishal.android.taskmanager.MyAlarmService.java
com.bishal.android.taskmanager.SCHEDULES.java
com.bishal.android.taskmanager.SEARCHING_PLACES.java
com.bishal.android.taskmanager.SIGNUP.java
com.bishal.android.taskmanager.Search_Education.java
com.bishal.android.taskmanager.Search_Hospital.java
com.bishal.android.taskmanager.SpecifyTime.java
com.bishal.android.taskmanager.TaskManagerActivity.java
com.bishal.android.taskmanager.TaskManagerApplication.java
com.bishal.android.taskmanager.ViewTasksActivity.java
com.bishal.android.taskmanager.YourAlarmService.java
com.bishal.android.taskmanager.adapters.TaskListAdapter.java
com.bishal.android.taskmanager.tasks.Task.java
com.bishal.android.taskmanager.tasks.TasksSQLiteOpenHelper.java
com.bishal.android.taskmanager.views.AddressOverlay.java
com.bishal.android.taskmanager.views.TaskListItem.java