-2
我正在使用SQL將用戶數據存儲在Android應用程序中。應用程序工作正常,但在更新新用戶時崩潰。 我在分享我的代碼。Android應用程序在註冊時崩潰
SQLiteDatabase
data=openOrCreateDatabase("fun",MODE_PRIVATE,null);
data.execSQL("create table if not exists tabl(sim varchar, name varchar, user varchar,password varchar)");
String st="select * from tabl where user='"+mail+"'";
Cursor cursor=data.rawQuery(st,null);
if(cursor.getCount()>0)
{
Toast.makeText(Register.this, "Username already used!", Toast.LENGTH_SHORT).show();
}
else
{
data.execSQL("insert into tabl values('"+simno+"',"+fname+"','"+mail+"','"+pass+"')");
Toast.makeText(Register.this, "Registered!", Toast.LENGTH_SHORT).show();
Intent log=new Intent(Register.this,Sender.class);
startActivity(log);
finish();
}
向我們顯示錯誤 – ImAtWar
您無法命名您的表'DATABASE',因爲這是一個保留關鍵字。 –
按下注冊按鈕後,應用程序停止工作。 –