Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8463849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:34:07+00:00 2026-06-10T14:34:07+00:00

I have been getting a problem with creating a table in Android. I had

  • 0

I have been getting a problem with creating a table in Android.

I had the table, but it was an older version so I had to drop it. After this I could not get it to create another table and I can’t figure out why. I get error “no such table user_login”

Here is my class for the database

public class Database  extends SQLiteOpenHelper {

private static final int DATABASE_VERSION = 1;

private static final String DB_name = "aeglea";
private static final String TABLE_NAME = "user_login";
//private static final String KEY_ID = "id";
private static final String KEY_UID = "uid";
private static final String KEY_NAME = "name";
private static final String KEY_LAST = "last";
private static final String KEY_EMAIL = "email";
private static final String KEY_USERNAME = "username";

public Database(Context context) {
    super(context, DB_name, null, DATABASE_VERSION);
}


public void onCreate(SQLiteDatabase db) {
    String CREATE_LOGIN_TABLE = "CREATE TABLE " + TABLE_NAME + "("
            + KEY_UID + " INTEGER PRIMARY KEY,"
            + KEY_NAME + " TEXT,"
            + KEY_LAST + " TEXT,"
            + KEY_EMAIL + " TEXT UNIQUE,"
            + KEY_USERNAME + " TEXT UNIQUE" + ")";

    db.execSQL(CREATE_LOGIN_TABLE);


}


public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    // Drop older table if existed
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
     // Create tables again
    onCreate(db);

}

public void addUser(int uid, String name, String last, String email, String username) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();

    values.put(KEY_UID, uid); // user id
    values.put(KEY_NAME, name); // Name
    values.put(KEY_LAST, last); //last
    values.put(KEY_EMAIL, email); // Email
    values.put(KEY_USERNAME, username); // User name

    // Inserting Row
    db.insert(TABLE_NAME, null, values);
    db.close(); // Closing database connection
}

public void resetTables(){
    SQLiteDatabase db = this.getWritableDatabase();
    // Delete All Rows
    db.delete(TABLE_NAME, null, null);
    db.close();
}

/**
 * Getting user data from database
 * */
public HashMap<String, String> getUserDetails(){
    HashMap<String,String> user = new HashMap<String,String>();
    String query = "SELECT  * FROM " + TABLE_NAME;//make query

    SQLiteDatabase db = this.getReadableDatabase();
    Cursor cursor = db.rawQuery(query, null);//do query
    // Move to first row
    cursor.moveToFirst();
    if(cursor.getCount() > 0){
        user.put("uid", cursor.getString(1));
        user.put("name", cursor.getString(2));
        user.put("last",cursor.getString(3));
        user.put("email", cursor.getString(4));
        user.put("username", cursor.getString(5));

    }
    cursor.close();
    db.close();
    // return user
    return user;
}


/**
 * Getting user login status
 * return true if rows are there in table
 * */
public int getRowCount() {
    String countQuery = "SELECT  * FROM " + TABLE_NAME;
    SQLiteDatabase db = this.getReadableDatabase();


    Cursor cursor = db.rawQuery(countQuery, null);
    int rowCount = cursor.getCount();
    db.close();
    cursor.close();

    // return row count
    return rowCount;
}

}

And here is the main class where I use the database(look at the bottom)

public class login2 extends Activity {
private EditText un,pw;
TextView error;
Button ok;
private JSONObject jo2;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    un=(EditText)findViewById(R.id.et_un);
    pw=(EditText)findViewById(R.id.et_pw);
    ok=(Button)findViewById(R.id.btn_login);
    error=(TextView)findViewById(R.id.tv_error);

    ok.setOnClickListener(new View.OnClickListener() {

    private Database db = new Database(getApplicationContext());    

        public void onClick(View v) {
            // TODO Auto-generated method stub

            ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
            postParameters.add(new BasicNameValuePair("username", un.getText().toString()));
            postParameters.add(new BasicNameValuePair("password", pw.getText().toString()));
            //String valid = "1";
            JSONObject response = null;
            try {
                response = CustomHttpClient.executeHttpPost("http://ironis.dyndns.org/aeglea/android/log.php", postParameters);
               // String res=response.toString();
               // res = res.trim();
                //res= res.replaceAll("\\s+","");                            
                //error.setText(res);

               if(response.getString("success").equals("1")){
                    error.setText(response.getString("last"));
                    //store user to database in success

                    //reset older entries
                    db.resetTables();
                    //add user
                    db.addUser(Integer.parseInt(response.getString("id")), response.getString("name"), response.getString("last"), response.getString("email"), response.getString("username"));

               }else{
                    error.setText(response.getString("error_msg"));
                    } 
            } catch (Exception e) {
                un.setText(e.toString());
            }

        }
    });
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:34:08+00:00Added an answer on June 10, 2026 at 2:34 pm

    you should change your database version like :

    private static final int DATABASE_VERSION = 2
    

    ithink if you change version you dont need to drop older table. the new table will replace it.

    maybe it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to figure out why I am getting this problem and
I have been working on getting this seat mapping chart for a while and
I've got a table that people have been inserting into getting the primary key
I have looked at all the examples related to this but have not been
I have been getting an invalid character! on what looks like the £ sign
I've taken a screenshot of the compiler inconsistencies that I have been getting when
On several of my adsense running sites, I have been getting the following errors:
I have been working on getting a mail app to work from a tutorial
I have been working on getting my OSGi application to run outside eclipse. It
I have been trying to find a way of getting a windows batch file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.