Android Open Source - AndroidSqlite Android Sqlite Text






From Project

Back to project page AndroidSqlite.

License

The source code is released under:

Apache License

If you think the Android project AndroidSqlite listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.ffmmx.example.androidsqlite2.activity;
/*from www.  jav  a 2s.  c o  m*/
import java.text.ParseException;

import org.ffmmx.example.androidsqlite2.R;
import org.ffmmx.example.androidsqlite2.business.Login;
import org.ffmmx.example.androidsqlite2.common.SqlUtil;

import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class AndroidSqliteText extends Activity {
  private EditText usernameEdit, passwordEdit;
  private Button loginBtn, registerBtn;
  private SQLiteOpenHelper sqlhelper;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    if (Login.isLogon()) {
      Intent intent = new Intent();
      intent.setClass(AndroidSqliteText.this, NoteActivity.class);
    }

    sqlhelper = new SqlUtil(AndroidSqliteText.this);

    usernameEdit = (EditText) this.findViewById(R.id.usernameEdit);
    passwordEdit = (EditText) this.findViewById(R.id.passwordEdit);
    loginBtn = (Button) this.findViewById(R.id.loginBtn);
    registerBtn = (Button) this.findViewById(R.id.registerBtn);
    OnClickListener clickLisenter = new ClickLisenter();
    loginBtn.setOnClickListener(clickLisenter);
    registerBtn.setOnClickListener(clickLisenter);

  }

  class ClickLisenter implements OnClickListener {

    @Override
    public void onClick(View v) {
      switch (v.getId()) {
      case R.id.loginBtn:
        SQLiteDatabase db = sqlhelper.getReadableDatabase();
        boolean result = false;
        try {
          result = Login.login(db, usernameEdit.getText().toString(),
              passwordEdit.getText().toString());
        } catch (ParseException e) {
          e.printStackTrace();
        }
        db.close();
        if (result) {
          Intent intent = new Intent();
          intent.setClass(AndroidSqliteText.this, NoteActivity.class);
          startActivity(intent);
        } else {
          Toast.makeText(AndroidSqliteText.this, "??????????????????",
              Toast.LENGTH_LONG).show();

        }
        break;
      case R.id.registerBtn:
        Intent intent = new Intent();
        intent.setClass(AndroidSqliteText.this, RegisterActivity.class);
        startActivity(intent);
        break;
      default:
        break;
      }
    }

  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.android_sqlite_text, menu);
    return true;
  }

}




Java Source Code List

org.ffmmx.example.androidsqlite2.activity.AndroidSqliteText.java
org.ffmmx.example.androidsqlite2.activity.RegisterActivity.java
org.ffmmx.example.androidsqlite2.business.Login.java
org.ffmmx.example.androidsqlite2.business.Register.java
org.ffmmx.example.androidsqlite2.common.CommonUtil.java
org.ffmmx.example.androidsqlite2.common.SqlUtil.java
org.ffmmx.example.androidsqlite2.domain.User.java