When i am calling the my already created data base in SQ lite.It giving the Run time Exception that data base is calling recursively.but every time the data base use is over i closed it.
what is going wrong with it?i am using eclipse and developing program in android.
i creating the object of helper class(In which i created the database).and and then
using SQliteDatabase db=hc.getWritebleDatabase();
Exception is in the above line
hc=helperclass object
answer me..because on Google i didn’t get any related answer.
code getting Exception:::
i have already a data base class named HelperClass .its had table named New_User
public void check_pass()
{
boolean flag=true;
private HelperClass hc = new HelperClass(this);
SQLiteDatabase db;
try{ db=hc.getWritableDatabase();}
catch(Exception ex)
{
Toast.makeText(this,""+ex.getMessage(),Toast.LENGTH_SHORT).show();
}
cur=db.query("New_User",null,null,null,null,null,null);
cur.moveToFirst();
do{
if(cur.getString(0).equalsIgnoreCase(edittext_name.getText().toString())&&cur.getString(3).equals(edittext_pass.getText().toString())){
flag=false;
//dialog = ProgressDialog.show(MainActivity.this,"","Please wait for few seconds...", true);
//dialog.setCancelable(true);
//dialog.show();
Intent intent1=new Intent(this,Friends.class);
startActivity(intent1);
}
cur.moveToNext();
} while(cur.moveToNext());
if(flag==true){
Toast.makeText(this,"Incorecct user name or password",Toast.LENGTH_SHORT).show();
}
data base Creation:
public class HelperClass extends SQLiteOpenHelper {
public final static String Db_name="employee.db";
protected final static int Db_version=1;
protected final static String Ename="Ename";
protected final static String Email="Email";
protected final static String Epass="Epass";
protected final static String Eabout="Eabout";
protected final static String Egender="Egender";
protected final static String Ehob1="Ehob1";
protected final static String Ehob2="Ehob2";
protected final static String Ehob3="Ehob3";
protected final static String Ehob4="Ehob4";
public HelperClass(Context context){
super(context,Db_name,null,Db_version);
}
public void onCreate(SQLiteDatabase db1){
db1=this.getWritableDatabase();
String sql= "CREATE TABLE New_User("+Ename +" text not null," +
""+ Egender +" text not null," +
""+ Email +" text not null primary key," +
"" +Epass+" text not null,"+
""+ Eabout +" text not null,"+
""+ Ehob1 +" text,"+ Ehob2 +" text,"+ Ehob3 +" text,"+ Ehob4 +" text);";
db1.execSQL(sql);
}
Remove this line:
So your database onCreate method should be: