when click on submit button shows error.
database.java
package k.l; import android.content.context; import android.database.sqlite.sqlitedatabase; import android.database.sqlite.sqlitedatabase.cursorfactory; import android.database.sqlite.sqliteopenhelper; public class database extends sqliteopenhelper{ public static final string dbname="mydb.db"; public static final string dtab="mytution"; public static final string name="name"; public static final string passwrd="passwrd"; public static final string address="address"; public static final string email="email"; public static final string phone="phone"; public static final int dver=5; public database(context context, string name, cursorfactory factory, int version) { super(context,dbname, factory, 5); // todo auto-generated constructor stub } @override public void oncreate(sqlitedatabase db) { // todo auto-generated method stub string str="create table mytution(name text not null,passwrd text not null,address text,email text not null,phone text);"; db.execsql(str); } @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { // todo auto-generated method stub } }
login.java
package k.l; import android.app.activity; import android.content.contentvalues; import android.database.sqlite.sqlitedatabase; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; import android.widget.toast; public class login extends activity{ edittext name,addr,phn,pswd,emailid; button submit; database db1=new database(this, "mydb.db", null, 5); protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.login); name=(edittext)findviewbyid(r.id.name); addr=(edittext)findviewbyid(r.id.address); phn=(edittext)findviewbyid(r.id.phn); pswd=(edittext)findviewbyid(r.id.password); emailid=(edittext)findviewbyid(r.id.email); submit=(button)findviewbyid(r.id.signin); submit.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub add(); toast.maketext(getapplicationcontext(), "succefully registered!", 1000).show(); } }); } public void add(){ sqlitedatabase sqldb=db1.getwritabledatabase(); contentvalues cv=new contentvalues(); cv.put(database.name, name.gettext().tostring()); cv.put(database.passwrd, pswd.gettext().tostring()); cv.put(database.phone, phn.gettext().tostring()); cv.put(database.email, emailid.gettext().tostring()); cv.put(database.address, addr.gettext().tostring()); sqldb.insert(database.dtab,null, cv); } }
login.xml
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/page2"> <textview android:layout_height="wrap_content" android:layout_width="wrap_content" /> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <textview android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="name" android:textcolor="#9a32cd" android:textstyle="bold"/> <edittext android:id="@+id/name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputtype="textpersonname" /> </linearlayout> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <textview android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="password" android:textcolor="#9a32cd" android:textstyle="bold"/> <edittext android:layout_height="wrap_content" android:layout_width="fill_parent" android:inputtype="textpassword" android:id="@+id/password" /> </linearlayout> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <textview android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="email id" android:textcolor="#9a32cd" android:textstyle="bold"/> <edittext android:id="@+id/email" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputtype="textemailaddress" > <requestfocus /> </edittext> </linearlayout> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="phone no" android:textcolor="#9a32cd" android:textstyle="bold" /> <edittext android:id="@+id/phn" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0.15" android:inputtype="number" /> </linearlayout> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <textview android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="address" android:textcolor="#9a32cd" android:textstyle="bold"/> <edittext android:id="@+id/address" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputtype="textpostaladdress" /> </linearlayout> <textview android:layout_height="wrap_content" android:layout_width="wrap_content" /> <button android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/signin" android:text="create account" android:textstyle="bold" android:textcolor="#8b475d" android:layout_gravity="center"/> </linearlayout>
error - 07-15 14:26:08.071: i/database(323): sqlite returned: error code = 1, msg = table mytution has no column named passwrd
steps checking database using ddms , sqlite manager
- first install sqlite manager.
- open ddms in file explorer tab go data inside data select data.
- navigate folder named project name inside folder goto database , select database file.
- pull file , save computer.
- open sqlitemanager , open same file in sqlite manager , check table structure.
Comments
Post a Comment