Note that there are some explanatory texts on larger screens.

plurals
  1. POActivity getting stopped
    primarykey
    data
    text
    <p>Hi I have tried to create an activity including a database , but while running the application it is showing some syntax error and suddenly getting stopped. I have tried adjusting the space on the syntax but it is not working ,I need some suggestions to overcome my error. I am giving my log cat below</p> <pre><code>08-16 06:47:55.830: E/AndroidRuntime(1718): FATAL EXCEPTION: main 08-16 06:47:55.830: E/AndroidRuntime(1718): android.database.sqlite.SQLiteException: near "tableLOGINDETAILS": syntax error (code 1): , while compiling: create tableLOGINDETAILS( ID integer primary key autoincrement, USERNAME text , PASSWORD text , EMPLOYEE_CODE text , MOBILE integer ); 08-16 06:47:55.830: E/AndroidRuntime(1718): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) 08-16 06:47:55.830: E/AndroidRuntime(1718): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882) 08-16 06:47:55.830: E/AndroidRuntime(1718): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493) </code></pre> <p>this is the code</p> <pre><code> static final String DATABASE_NAME="LOGINDETAILS.db"; static final int DATABASE_VERSION=1; public static final int NAME_COLUMN=1; static final String DATABASE_CREATE = "create table" // create a Sql query for database + "LOGINDETAILS" + "(" + " ID " + "integer primary key autoincrement," + " USERNAME text , PASSWORD text , EMPLOYEE_CODE text , MOBILE integer );" ; public SQLiteDatabase db; private final Context context; private DataBaseHelper dbHelper; public LoginDataBaseAdapter(Context _context) { context=_context; dbHelper=new DataBaseHelper(_context, DATABASE_NAME, null, DATABASE_VERSION); } public LoginDataBaseAdapter open()throws SQLException { db=dbHelper.getWritableDatabase(); return this; } public void close() { db.close(); } public SQLiteDatabase getDatabaseInstance() { return db; } public void insertEntry(String User_name,String Password,String Emp_code,String Mob) { ContentValues newValues=new ContentValues(); //Assign values for each column newValues.put("USERNAME", User_name); newValues.put("PASSWORD", Password); newValues.put("EMPLOYEE_CODE", Emp_code); newValues.put("MOBILE", Mob); //Insert the row into the table db.insert("LOGINDETAILS", null, newValues); Toast.makeText(context, "User Info Saved", Toast.LENGTH_LONG).show(); } //Method to delete a record of username public int deleteEntry(String User_name) { String where ="USERNAME=?"; int numberOFEntriesDeleted=db.delete("LOGINDETAILS", where,new String[] {User_name}); Toast.makeText(context, "No of entry deleted successfully : "+numberOFEntriesDeleted, Toast.LENGTH_LONG).show(); return numberOFEntriesDeleted; } // method to get the password of the username public String getSingleEntry(String User_name) { Cursor cursor=db.query("LOGINDETAILS", null, "USERNAME=?", new String[] {User_name},null, null, null); if(cursor.getCount()&lt;1) //No user exist return "NOT EXIST"; cursor.moveToFirst(); String Password=cursor.getString(cursor.getColumnIndex("PASSWORD")); return Password; } // Method to update an existing record public void updateEntry(String User_name,String Password) { //Create object of content values ContentValues updatedValues=new ContentValues(); // Assign values for each item updatedValues.put("USERNAME", User_name); updatedValues.put("PASSWORD", Password); String where="USERNAME=?"; db.update("LOGINDETAILS", updatedValues, where, new String[] {User_name}); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload