2017-05-27 38 views
-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(); 
       } 
+1

向我們顯示錯誤 – ImAtWar

+1

您無法命名您的表'DATABASE',因爲這是一個保留關鍵字。 –

+0

按下注冊按鈕後,應用程序停止工作。 –

回答

0

有一些關鍵字和保留字不能簡單地用於命名錶或其他屬性,「數據庫」就是其中之一。請將您的表格名稱更改爲其他名稱。這link顯示完整列表。