Exemplo n.º 1
0
  public void onEnterInputMethod() {
    if (!copying && !db.isOpen()) {
      db = SQLiteDatabase.openDatabase(_dbpath, null, SQLiteDatabase.OPEN_READONLY);
      db.setLocale(Locale.TRADITIONAL_CHINESE);
    }

    inputBufferRaw.delete(0, inputBufferRaw.length());
    updateCandidates();
  }
Exemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.update_student);

    update_no = (TextView) findViewById(R.id.deleteNoView);
    update_name = (EditText) findViewById(R.id.et_name_update);
    update_grade = (EditText) findViewById(R.id.et_grade_update);
    update_callNum = (EditText) findViewById(R.id.et_callNum_update);
    updateOkBtn = (Button) findViewById(R.id.updateOkBtn);
    gotoListBtn = (Button) findViewById(R.id.listgoBtn_update);

    mDatabase = openOrCreateDatabase("students.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);

    mDatabase.setLocale(Locale.getDefault()); // 기본 지역
    mDatabase.setLockingEnabled(true); // 스레드에 락 설정
    mDatabase.setVersion(3); // 버전 설정

    update_no.setText(getInfo());
    update_name.setText(getInfo1());
    update_grade.setText(getInfo2());
    update_callNum.setText(getInfo3());

    updateOkBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            ContentValues values = new ContentValues();
            values.put("name", update_name.getText().toString());
            values.put("grade", update_grade.getText().toString());
            values.put("callnum", update_callNum.getText().toString());

            int result =
                mDatabase.update(
                    "students", values, "_id=?", new String[] {update_no.getText().toString()});

            Log.i("testLog", "update result>>>" + result);
            Toast.makeText(getApplicationContext(), "행 수정 성공", Toast.LENGTH_SHORT).show();

            update_name.setText("");
            update_grade.setText("");
            update_callNum.setText("");
          }
        });

    gotoListBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Intent listintent = new Intent(Update_Student.this, List_Students.class);
            startActivity(listintent);
          }
        });
  }
Exemplo n.º 3
0
    /**
     * Create the db from scratch.
     *
     * @param context the context to use.
     * @throws IOException if something goes wrong.
     */
    public void create(Context context) throws IOException {
      db.setLocale(Locale.getDefault());
      db.setVersion(DATABASE_VERSION);

      // CREATE TABLES
      GPLog.createTables(db);
      DaoMetadata.createTables();
      DaoMetadata.initProjectMetadata(null, null, null, null);
      DaoNotes.createTables();
      DaoGpsLog.createTables();
      DaoBookmarks.createTables();
      DaoImages.createTables();
    }
Exemplo n.º 4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.delete_student);

    deleteNo = (TextView) findViewById(R.id.noView_delete);
    deleteName = (TextView) findViewById(R.id.nameView_delete);
    deleteGrade = (TextView) findViewById(R.id.gradeView_delete);
    deleteCallNum = (TextView) findViewById(R.id.callNumView_delete);

    deleteOkBtn = (Button) findViewById(R.id.DeleteOkBtn);
    listOkBtn = (Button) findViewById(R.id.gotoListBtn_delete);

    mDatabase = openOrCreateDatabase("students.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);

    mDatabase.setLocale(Locale.getDefault()); // 기본 지역
    mDatabase.setLockingEnabled(true); // 스레드에 락 설정
    mDatabase.setVersion(3); // 버전 설정

    deleteNo.setText(getInfo());
    deleteName.setText(getInfo1());
    deleteGrade.setText(getInfo2());
    deleteCallNum.setText(getInfo3());

    deleteOkBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            int result =
                mDatabase.delete("students", "_id=?", new String[] {deleteNo.getText().toString()});
            Log.i("testLog", "delete result>>>" + result);
            Toast.makeText(getApplicationContext(), "행 삭제 성공", Toast.LENGTH_SHORT).show();

            Intent intent = new Intent(Delete_Student.this, List_Students.class);
            startActivity(intent);
          }
        });
    listOkBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Intent intent = new Intent(Delete_Student.this, List_Students.class);
            startActivity(intent);
          }
        });
  }
  @MediumTest
  public void testLocaleenUS() throws Exception {
    insertStrings();
    Log.i("LocaleTest", "about to call setLocale en_US");
    mDatabase.setLocale(new Locale("en", "US"));
    String[] results;
    results = query("SELECT data FROM test ORDER BY data COLLATE LOCALIZED ASC");

    // The database code currently uses PRIMARY collation strength,
    // meaning that all versions of a character compare equal (regardless
    // of case or accents), leaving the "cote" flavors in database order.
    MoreAsserts.assertEquals(
        results,
        new String[] {
          STRINGS[4], // "boy"
          STRINGS[0], // sundry forms of "cote"
          STRINGS[1],
          STRINGS[2],
          STRINGS[3],
          STRINGS[6], // "COTE"
          STRINGS[5], // "dog"
        });
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final SQLiteDatabase db;

    db = openOrCreateDatabase("TestingData.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
    db.setVersion(1);
    db.setLocale(Locale.getDefault());
    db.setLockingEnabled(true);

    final String CREATE_TABLE_COURSES =
        "CREATE TABLE IF NOT EXISTS courses ("
            + "id INTEGER PRIMARY KEY AUTOINCREMENT,"
            + "course_name TEXT,"
            + "course_tutor TEXT,"
            + "course_summary TEXT"
            + ");";
    final String CREATE_TABLE_STUDENTS =
        "CREATE TABLE IF NOT EXISTS students ("
            + "id INTEGER PRIMARY KEY AUTOINCREMENT,"
            + "student_name TEXT,"
            + "student_rollno INTEGER NOT NULL , "
            + "student_location TEXT,"
            + "student_email TEXT,"
            + "student_phone INT"
            + ");";
    final String CREATE_TABLE_CS =
        "CREATE TABLE IF NOT EXISTS cs ("
            + "id INTEGER PRIMARY KEY AUTOINCREMENT,"
            + "student_id INTEGER NOT NULL CONSTRAINT "
            + "student_id REFERENCES students(student_rollno) "
            + "ON DELETE CASCADE,"
            + "course_id NOT NULL CONSTRAINT "
            + "course_id REFERENCES courses(course_name) "
            + "ON DELETE CASCADE,"
            + "grade TEXT,"
            + "sem TEXT"
            + ");";

    //        if(flag==0)
    //        {
    //        	db.execSQL("DROP TABLE IF EXISTS courses");
    //        	db.execSQL("DROP TABLE IF EXISTS students");
    //        	db.execSQL("DROP TABLE IF EXISTS cs");
    //        	flag=1;
    //        }

    db.execSQL(CREATE_TABLE_COURSES);
    db.execSQL(CREATE_TABLE_STUDENTS);
    db.execSQL(CREATE_TABLE_CS);

    final String CREATE_TRIGGER_STUDENTS =
        "CREATE TRIGGER IF NOT EXISTS fk_cs_studentid "
            + " BEFORE INSERT "
            + " ON cs"
            + " FOR EACH ROW BEGIN"
            + " SELECT CASE WHEN ((SELECT id  FROM students"
            + "  WHERE id=new.student_id ) IS NULL)"
            + " THEN RAISE (ABORT,'Foreign Key Violation') END;"
            + "  END;";
    final String CREATE_TRIGGER_COURSES =
        "CREATE TRIGGER IF NOT EXISTS fk_cs_courseid "
            + " BEFORE INSERT "
            + " ON cs"
            + " FOR EACH ROW BEGIN"
            + " SELECT CASE WHEN ((SELECT id  FROM courses"
            + "  WHERE id=new.course_id ) IS NULL)"
            + " THEN RAISE (ABORT,'Foreign Key Violation') END;"
            + "  END;";
    db.execSQL(CREATE_TRIGGER_COURSES);
    db.execSQL(CREATE_TRIGGER_STUDENTS);

    final Context context = getApplicationContext();

    Button b1 = (Button) findViewById(R.id.button1);
    //       Log.v("uhuh","asdjasld");
    b1.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Button addstud = (Button) v;
            Intent i = new Intent(context, student_details.class);
            startActivity(i);
          }
        });

    Button b2 = (Button) findViewById(R.id.button2);
    b2.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Button addstud = (Button) v;
            Intent i = new Intent(context, course_details.class);
            startActivity(i);
          }
        });

    Button b3 = (Button) findViewById(R.id.button3);
    b3.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Button addstud = (Button) v;
            Intent i = new Intent(context, register.class);
            startActivity(i);
          }
        });

    Button b4 = (Button) findViewById(R.id.resetdb);
    b4.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Button addstud = (Button) v;
            db.execSQL("DROP TABLE IF EXISTS courses");
            db.execSQL("DROP TABLE IF EXISTS students");
            db.execSQL("DROP TABLE IF EXISTS cs");

            db.execSQL(CREATE_TABLE_COURSES);
            db.execSQL(CREATE_TABLE_STUDENTS);
            db.execSQL(CREATE_TABLE_CS);
          }
        });

    Button b5 = (Button) findViewById(R.id.upgrade_button);
    b5.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Button addstud = (Button) v;
            Intent i = new Intent(context, upgrade.class);
            startActivity(i);
          }
        });

    Button b6 = (Button) findViewById(R.id.report_button);
    b6.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Button addstud = (Button) v;
            Intent i = new Intent(context, get_report.class);
            startActivity(i);
          }
        });
  }
Exemplo n.º 7
0
  /** function to pass the timer limit and user log to the class to calculate score */
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.test2);

    TextView sit = (TextView) findViewById(R.id.test222textView1);
    Typeface font1 = Typeface.createFromAsset(getAssets(), "CANDARA.TTF");
    sit.setTypeface(font1);
    Bundle bundle = getIntent().getExtras();
    final String s = bundle.getString("un");
    final int g = bundle.getInt("un1");
    final long ter = g * 1000;
    // Toast.makeText(getApplicationContext(),String.valueOf(g),Toast.LENGTH_LONG).show();
    qb1 = (Button) findViewById(R.id.qbutton1);
    ctr = (TextView) findViewById(R.id.ctr);
    // timer code
    TimerTask task =
        new TimerTask() {
          @Override
          public void run() {
            elapsed += INTERVAL;
            if (elapsed >= ter) {

              this.cancel();
              vend();
              displayText("Time Up!!");
              // boolean ab=qb1.performClick();
              return;
            }
            displayText("Time: " + (ter - elapsed) / 1000);
          }
        };

    Timer timer = new Timer();
    timer.scheduleAtFixedRate(task, INTERVAL, INTERVAL);

    TextView tt1 = (TextView) findViewById(R.id.test2textView2);
    r1 = (RadioButton) findViewById(R.id.option1);
    r2 = (RadioButton) findViewById(R.id.option2);
    r3 = (RadioButton) findViewById(R.id.option3);

    Random randomGenerator = new Random();
    Random randomGenerator2 = new Random();

    int a = randomGenerator.nextInt(866);
    String quest;
    final String ans1;
    String ans2, ans3;

    // Toast.makeText(getApplicationContext(),String.valueOf(a) , Toast.LENGTH_LONG).show();
    /** opening the database */
    SQLiteDatabase db;
    db = openOrCreateDatabase("vocab.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
    db.setVersion(1);
    db.setLocale(Locale.getDefault());
    db.setLockingEnabled(true);
    Cursor cur = db.query("words", null, null, null, null, null, null);
    Cursor cur2 = db.query("tes", null, null, null, null, null, null);
    cur.moveToFirst();
    cur2.moveToFirst();
    TextView ty = (TextView) findViewById(R.id.testindex);
    ty.append(cur2.getString(1));
    ty.append(".");
    cur.moveToPosition(a);
    quest = cur.getString(2);
    ans1 = cur.getString(1);
    cur.moveToPosition((a + 1) % 867);
    ans2 = cur.getString(1);
    cur.moveToPosition((a + 2) % 867);
    ans3 = cur.getString(1);
    tt1.setText(quest);
    r1.setClickable(true);
    r2.setClickable(true);
    r3.setClickable(true);

    int b = randomGenerator2.nextInt(3);
    // Toast.makeText(getApplicationContext(), String.valueOf(b),Toast.LENGTH_LONG).show();
    /** shuffling the answer */
    if (b == 0) {
      r1.setText(ans1);
      r2.setText(ans2);
      r3.setText(ans3);
    } else if (b == 1) {
      r1.setText(ans3);
      r2.setText(ans1);
      r3.setText(ans2);
    } else if (b == 2) {
      r1.setText(ans2);
      r2.setText(ans3);
      r3.setText(ans1);
    }

    qb1.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            int tep = 0, tep2;
            /** opening the database */
            SQLiteDatabase db;
            db = openOrCreateDatabase("vocab.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
            db.setVersion(1);
            db.setLocale(Locale.getDefault());
            db.setLockingEnabled(true);
            ContentValues values = new ContentValues();
            Cursor cur2 = db.query("tes", null, null, null, null, null, null);
            cur2.moveToFirst();
            /** check for user answer */
            String uans = "";

            if (r1.isChecked() == true) {
              uans = r1.getText().toString();

            } else if (r2.isChecked() == true) {
              uans = r2.getText().toString();

            } else if (r3.isChecked() == true) {
              uans = r3.getText().toString();
            }
            /** updation of the database with respect to the user selection of answer */

            /** action script when the user's answer is correct */
            if (uans.equals(ans1)) {
              tep = Integer.parseInt(cur2.getString(0));
              tep2 = Integer.parseInt(cur2.getString(1));
              tep++;
              tep2++;
              values.put("score", tep);
              values.put("count", tep2);
              db.update("tes", values, "ven=?", new String[] {"11"});

            }
            /** action script when the answer is wrong */
            else {
              /** printing the right answer when the user's answer is wrong */
              Toast.makeText(
                      getApplicationContext(), "The right answer : " + ans1, Toast.LENGTH_SHORT)
                  .show();

              tep2 = Integer.parseInt(cur2.getString(1));
              tep2++;
              values.put("count", tep2);
              db.update("tes", values, "ven=?", new String[] {"11"});
            }

            //	Toast.makeText(getApplicationContext(), String.valueOf(tep),
            // Toast.LENGTH_LONG).show();
            //	Toast.makeText(getApplicationContext(), String.valueOf(tep2),
            // Toast.LENGTH_LONG).show();

            /** moving to result1 class after the quiz gets over to calculate score */
            if (tep2 == 16) {
              Intent i = new Intent(Test2.this, Result1.class);
              Bundle bundle = new Bundle();
              bundle.putString("un", s);
              i.putExtras(bundle);
              startActivity(i);
              finish();
            }
            /** generating different questions */
            else {
              /** intent that defines the action after the last question */
              Intent i = new Intent(Test2.this, Test2.class);
              Bundle bundle = new Bundle();
              bundle.putString("un", s);
              bundle.putInt("un1", g);
              i.putExtras(bundle);
              startActivity(i);
              finish();
            }
          }
        });
    db.close();
  }
Exemplo n.º 8
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bet);

    TextView sit = (TextView) findViewById(R.id.bettitle);
    Typeface font1 = Typeface.createFromAsset(getAssets(), "CANDARA.TTF");
    sit.setTypeface(font1);

    /** opening the database */
    SQLiteDatabase db;
    db = openOrCreateDatabase("vocab.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
    db.setVersion(1);
    db.setLocale(Locale.getDefault());
    db.setLockingEnabled(true);
    Cursor cur = db.query("profiles", null, null, null, null, null, null);
    cur.moveToFirst();

    /** populating the array with the list of users available */
    String[] pro = new String[cur.getCount()];
    if (cur.getCount() > 0) {
      pro = new String[cur.getCount()];
      int i = 0;
      do {
        pro[i] = cur.getString(1);
        i++;
      } while (cur.moveToNext());
    }
    cur.close();
    db.close();

    final AutoCompleteTextView textview =
        (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, pro);
    textview.setAdapter(adapter);
    /** moving to the create profile class */
    Button bun2 = (Button) findViewById(R.id.betbutton1);
    bun2.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            Intent i = new Intent(Bet.this, Newuser.class);
            startActivity(i);
            finish();
          }
        });

    /** authenticating the user and taking him to his home page */
    Button bun1 = (Button) findViewById(R.id.betbutton2);
    bun1.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            String stt = textview.getText().toString();
            SQLiteDatabase db;
            db = openOrCreateDatabase("vocab.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
            db.setVersion(1);
            db.setLocale(Locale.getDefault());
            db.setLockingEnabled(true);
            Cursor cur = db.query("profiles", null, null, null, null, null, null);
            cur.moveToFirst();
            int y = 0;
            /** moving to the test class */
            while (cur.isAfterLast() == false) {
              if (cur.getString(1).equals(stt)) {
                y = 11;

                Intent navi = new Intent(Bet.this, Test1.class);
                Bundle bundle = new Bundle();
                bundle.putString("un", stt);
                navi.putExtras(bundle);
                startActivity(navi);
                finish();
                break;
              } else {
                cur.moveToNext();
              }
            }
            cur.close();
            db.close();
            if (y != 11) {
              Toast.makeText(
                      getApplicationContext(), "User Name does not exist!", Toast.LENGTH_LONG)
                  .show();
            }
          }
        });

    /** actionscript for the autocomplete textview */
    textview.setOnItemClickListener(
        new OnItemClickListener() { // int i=1;

          @Override
          public void onItemClick(AdapterView<?> adapter, View view, int pos, long arg3) {
            String st = adapter.getItemAtPosition(pos).toString();
            SQLiteDatabase db;
            db = openOrCreateDatabase("vocab.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
            db.setVersion(1);
            db.setLocale(Locale.getDefault());
            db.setLockingEnabled(true);
            Cursor cur = db.query("profiles", null, null, null, null, null, null);
            cur.moveToFirst();
            int x = 0;
            /** authenticating process */
            while (cur.isAfterLast() == false) {
              if (cur.getString(1).equals(st)) {
                x = 11;
                Intent navi = new Intent(Bet.this, Test1.class);
                Bundle bundle = new Bundle();
                bundle.putString("un", st);
                navi.putExtras(bundle);
                startActivity(navi);
                finish();
                break;
              } else {
                cur.moveToNext();
              }
            }
            cur.close();
            db.close();
            if (x != 11) {
              Toast.makeText(
                      getApplicationContext(), "User Name does not exist!", Toast.LENGTH_LONG)
                  .show();
            }
          }
        });
  }