0

First time ever using SQLite, I have been using an online tutorial which show me how to create a database and a table. My table should have 3 columns of TEXT type which are name, email and password. Unfortunately, it doesn't seem to work, and I really don't know why, i think it's due to this error

Caused by: android.database.sqlite.SQLiteException: near "CREATE_TABLE": syntax error (code 1): , while compiling: CREATE_TABLE Registered_Info(UserName TEXT,Password TEXT,Email TEXT);

Here is my code.

package com.example.wolfe_000.final_final_zeno;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * Created by wolfe_000 on 19/04/2015.
 */
public class DatabaseOperations extends SQLiteOpenHelper {

public static int database_version = 1;
public String CREATE_QUERY = "CREATE_TABLE "+ TableData.TableInfo.TABLE_NAME+"("+ TableData.TableInfo.USER_NAME+" TEXT,"+ TableData.TableInfo.USER_PASS+" TEXT,"+TableData.TableInfo.USER_EMAIL+" TEXT);";



public DatabaseOperations(Context context){
    super(context, TableData.TableInfo.DATABASE_NAME,null,database_version);
    Log.d("Database Operations", "Database Created");
}

@Override
public void onCreate(SQLiteDatabase sdb){
    sdb.execSQL(CREATE_QUERY);
    Log.d("Database Operations", "Database Created");
}

@Override
public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {

}

public void putInformation(DatabaseOperations dop, String name, String pass, String email){
    SQLiteDatabase SQ = dop.getWritableDatabase();
    ContentValues cv = new ContentValues();
    cv.put(TableData.TableInfo.USER_NAME, name);
    cv.put(TableData.TableInfo.USER_PASS, pass);
    cv.put(TableData.TableInfo.USER_EMAIL, email);
    long k = SQ.insert(TableData.TableInfo.TABLE_NAME,null, cv);
    Log.d("Database Operations", "One Raw Inserted");
}

}

The error occurs when I click my SignUp button using this code:

public void SignUpOnClick(View view ){
    user_name = USER_NAME.getText().toString();
    user_email = USER_EMAIL.getText().toString();
    user_pass = USER_PASS.getText().toString();

    DatabaseOperations DB = new DatabaseOperations(ctx);
    DB.putInformation(DB, user_name, user_email, user_pass);
    Toast.makeText(getBaseContext(), "Successfully Registered", Toast.LENGTH_LONG).show();
    finish();
}
1
  • 1
    it's CREATE TABLE not CREATE_TABLE Commented Apr 19, 2015 at 22:51

2 Answers 2

2

"CREATE TABLE" not "CREATE_TABLE" !!!!!

Sign up to request clarification or add additional context in comments.

Comments

1

the problem is here : CREATE TABLE not CREATE_TABLE

public String CREATE_QUERY = "CREATE TABLE "+ TableData.TableInfo.TABLE_NAME+"("+ TableData.TableInfo.USER_NAME+" TEXT,"+ TableData.TableInfo.USER_PASS+" TEXT,"+TableData.TableInfo.USER_EMAIL+" TEXT);";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.