@Override
 public void onCreate(Bundle icicle) {
   super.onCreate(icicle);
   setContentView(R.layout.mastersetlist);
   data = new DataBaseHelper(this);
   setTitle("Notification Settings");
   lv1 = (ListView) findViewById(R.id.list);
   lv1.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
   lv1.setAdapter(
       new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice, array));
   lv1.setTextFilterEnabled(true);
   lv1.setOnItemClickListener(this);
   Cursor c9 = data.getnotisettings();
   while (c9.moveToNext()) {
     flag = c9.getInt(0);
     System.out.println("Noti Flag will be......." + flag);
   }
   c9.close();
   Cursor c10 = data.getwinsettings();
   while (c10.moveToNext()) {
     flag1 = c10.getInt(0);
     System.out.println("Win Flag will be......." + flag1);
   }
   c10.close();
   if (flag == 1) {
     lv1.setItemChecked(0, true);
   } else if (flag1 == 1) {
     lv1.setItemChecked(1, true);
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_results);
    listView = (ListView) findViewById(R.id.listView);

    myDB = new DataBaseHelper(this);
    myDB.openDataBase();

    items = myDB.getplayersnames();
    if (items.isEmpty()) {
      listView.setVisibility(View.INVISIBLE);
      Toast.makeText(this, "لا توجد نتائج مسجلة", Toast.LENGTH_LONG).show();
    } else {
      listView.setAdapter(
          new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items));
    }
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String playername = items.get(position);
            results = myDB.getDataByName(playername);
            showSelectedResult(playername, results[0], results[1], results[2]);
          }
        });
  }
  private void NextQuestion() {

    List<QuestionLookupItem> list = cache.getQuestionsIds();
    // remove the question we have just answered

    // QuestionLookupItem  item = list.get(0);
    // Log.e("Joseph",item.get_id().toString());

    list.remove(0);
    // cache.setQuestionsIds(list);

    if (list.size() < 1) {
      // Finish here
      // QuestionLookupItem  item2 = list.get(0);
      Toast.makeText(
              getBaseContext(),
              String.valueOf(
                  "Test Finished ! "
                      + "Result is "
                      + Integer.toString(cache.getYourCorrectAnswerResult())
                      + " out of "
                      + Integer.toString(cache.getScorableQuestions())),
              Toast.LENGTH_LONG)
          .show();

      // Add Results to Database

      String Query =
          "INSERT INTO RESULTS "
              + " (CorrectAnswers,TotalQuestions)"
              + " Values ("
              + cache.getYourCorrectAnswerResult()
              + ", "
              + cache.getScorableQuestions()
              + " ); ";
      DataBaseHelper myDbHelper = new DataBaseHelper(getBaseContext());
      myDbHelper.InsertToDatabase(Query);

      // Go back to Customise Screen
      onBackPressed();
    } else {
      // Create a new list with the remainer of questions and add it to the cache
      List<QuestionLookupItem> mylist = new ArrayList<QuestionLookupItem>();

      for (int i = 0; i < list.size(); i++) {
        if (list.get(i).equals(null)) {

        } else {
          mylist.add(list.get(i));
        }
      }
      cache.setQuestionsIds(mylist);

      List<QuestionLookupItem> list1 = cache.getQuestionsIds();
      LoadQuestionViaTemplate(list1.get(0));
    }

    // Log.e("Joseph",item2.get_id().toString());

  }
  private void GetDataFromDatabase() {

    openDatabaseConnection();

    String[] Columns = {"CorrectAnswers", "TotalQuestions"};

    Cursor c = myDbHelper.query1("RESULTS", Columns, null, null, null, null, "_id DESC", "10");

    if (c.getCount() > 0) {

      sbCorrect = new StringBuilder();
      sbWrong = new StringBuilder();
      TotalArrays = new ArrayList<Integer>();

      if (c.moveToFirst()) {

        do {

          int CorrectVal = c.getInt(c.getColumnIndex("CorrectAnswers"));
          sbCorrect.append(Integer.toString(CorrectVal) + ",");

          int TotalVal = c.getInt(c.getColumnIndex("TotalQuestions"));
          int WrongVal = TotalVal - CorrectVal;
          sbWrong.append(Integer.toString(WrongVal) + ",");

          TotalArrays.add(TotalVal);

        } while (c.moveToNext());
      }
    }
    c.close();
    myDbHelper.close();
  }
  private void GetQuestion(Integer _id) {

    openDatabaseConnection();

    String WhereStatement = "_id " + "= " + String.valueOf(_id);
    String[] Columns = {"QUESTION"};

    Cursor c = myDbHelper.query("QUESTIONITEMS", Columns, WhereStatement, null, null, null, null);

    if (c.getCount() > 0) {

      c.moveToPosition(0);

      Question = c.getString(0);
    }
    // file remove extension
    String TrimmedQuestion = Question.subSequence(0, Question.lastIndexOf('.')).toString();

    Uri path = Uri.parse("file:///android_asset/QImages/" + TrimmedQuestion + ".jpeg");
    String HTML = "<img src=\"" + path.toString() + "\"" + " width=\"100%\"" + " />";

    final String mimeType = "text/html";
    final String encoding = "utf-8";

    QuestionHeaderBox.loadDataWithBaseURL("fakeit://not required", HTML, mimeType, encoding, null);

    // QuestionHeaderBox.getSettings().setInitialScale(75);
    c.close();
    myDbHelper.close();
  }
Example #6
0
 public Integer delete(Tarefa tarefa) {
   db = helper.getWritableDatabase();
   Integer ROWID = db.delete("tarefa", "id = ? ", new String[] {Integer.toString(tarefa.getId())});
   db.close();
   helper.close();
   return ROWID;
 }
  public static SQLiteDatabase getInstance() {
    if (dataBaseHelper == null) {
      dataBaseHelper = new DataBaseHelper(mContext);
      dataBaseHelper.openDataBase();
    }

    return dataBaseHelper.getWritableDatabase();
  }
  private void ConfigureTypeOfQuestion() {

    openDatabaseConnection();

    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);

    if (sharedPrefs.getString("typeofquestionPref", "").contentEquals("")
        || sharedPrefs.getString("typeofquestionPref", "").contentEquals("0")) {
      // If the is the first time app is started then add pref for Type of Question = 0 meaning ALL
      // or if the Pref is already 0 fill the txtbox with ALL;

      /*Toast.makeText(getBaseContext(),
      "Type of Q is empty",
      Toast.LENGTH_LONG).show();*/
      myDbHelper.close();

      SharedPreferences customSharedPreference =
          getSharedPreferences("typeofquestionPref", MODE_PRIVATE);

      SharedPreferences.Editor editor = customSharedPreference.edit();

      editor.putString("typeofquestionPref", "0");
      editor.commit();

      txtTypeofQuestion.setText("ALL");

    } else {

      String WhereStatement = "_id " + "= " + sharedPrefs.getString("typeofquestionPref", "");

      String[] Columns = {"DESCRIPTION"};

      Cursor c =
          myDbHelper.query(
              "QUESTIONTEMPLATE", Columns, WhereStatement, null, null, null, "DESCRIPTION");

      if (c.getCount() > 0) {

        c.moveToPosition(0);
        txtTypeofQuestion.setText(c.getString(0));

      } else {
        Toast.makeText(
                getBaseContext(),
                "Type of Question --Data missing from database: "
                    + sharedPrefs.getString("typeofquestionPref", ""),
                Toast.LENGTH_LONG)
            .show();
        txtTypeofQuestion.setText("ALL");
      }

      c.close();
      myDbHelper.close();
    }
  }
  public void onItemClick(AdapterView<?> a, View v, int position, long id) {
    System.out.println("Position" + position);
    if (position == 0) {
      data.updatensettings();
      data.updatewinsettings_zero();

    } else if (position == 1) {
      data.updatewinsettings();
      data.updatensettings_zero();
    }
  }
Example #10
0
 public void onPressClear(View view) {
   // Do something in response to button
   DataBaseHelper databasehelper = new DataBaseHelper(this);
   SQLiteDatabase db = databasehelper.getWritableDatabase();
   if (db != null) {
     // Se elimina la versión anterior de la tabla
     db.execSQL("DROP TABLE IF EXISTS " + databasehelper.TABLA);
     // Se utiliza para poder crear la nueva base de datos
     databasehelper.onCreate(db);
   }
 }
Example #11
0
  private Cursor wineQuery() {
    myDbHelper.openDataBase();
    mRegionCursor = myDbHelper.pairingGrenache();
    startManagingCursor(mRegionCursor);

    // Now create a simple cursor adapter and set it to display
    SimpleCursorAdapter adapter =
        new SimpleCursorAdapter(this, R.layout.pairing_item, mRegionCursor, FROM_WINE, TO_WINE);
    setListAdapter(adapter);
    myDbHelper.close();
    return mRegionCursor;
  }
Example #12
0
  // metodo para insertar a la tabla
  private void insertPrso(String nombre, String ciudad) {
    DataBaseHelper databasehelper = new DataBaseHelper(this);
    SQLiteDatabase db = databasehelper.getWritableDatabase();
    if (db != null) {
      ContentValues cv = new ContentValues();
      cv.put(DataBaseHelper.NOMBRE, nombre);
      cv.put(DataBaseHelper.CIUDAD, ciudad);

      db.insert("tabla", DataBaseHelper.NOMBRE, cv);
      db.close();
    }
  }
  @Override
  public boolean onCreate() {
    // TODO Auto-generated method stub
    DataBaseHelper dbHelper = new DataBaseHelper(getContext(), DB_FILENAME, null, DB_VERSION);

    try {
      db = dbHelper.getWritableDatabase();
      return true;
    } catch (SQLiteException sqle) {
      throw sqle;
    }
  }
Example #14
0
  private Cursor fillSaturday() {
    myDbHelper.openDataBase();
    mMuseumCursor = myDbHelper.listSaturday();
    startManagingCursor(mMuseumCursor);

    // Now create a simple cursor adapter and set it to display
    SimpleCursorAdapter adapter =
        new SimpleCursorAdapter(this, R.layout.listall, mMuseumCursor, FROM_FILL, TO);
    setListAdapter(adapter);
    myDbHelper.close();
    return mMuseumCursor;
  }
Example #15
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_name);

    name = (EditText) findViewById(R.id.NAME);
    submitName = (Button) findViewById(R.id.SETNAME);

    try {
      myDbHelper.createDataBase();
    } catch (IOException ioe) {
      throw new Error("Unable to create database");
    }

    try {
      myDbHelper.openDataBase();
    } catch (SQLException sqle) {
      throw sqle;
    }

    database = myDbHelper.getReadableDatabase();
    Cursor cursor;
    cursor = database.rawQuery(("select * from name"), null);
    cursor.moveToFirst();
    String Ric = new String();
    Ric = cursor.getString(cursor.getColumnIndex("name"));
    name.setText(Ric);
    database.close();

    submitName.setOnClickListener(
        new OnClickListener() {

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

            database = myDbHelper.getReadableDatabase();
            String clicked = name.getText().toString();
            Cursor cursor;
            cursor = database.rawQuery(("select * from name"), null);
            cursor.moveToFirst();
            String Ric = new String();
            Ric = cursor.getString(cursor.getColumnIndex("name"));
            database.delete("name", "name = '" + Ric + "'", null);
            ContentValues values = new ContentValues();
            values.put("name", clicked);
            database.insert("name", null, values);
            cursor.close();
            database.close();
          }
        });
  }
  public static List<Goal> getAll() {

    DataBaseHelper dataBaseHelper = DataBaseHelper.getIstance();
    SQLiteDatabase db = dataBaseHelper.getReadableDatabase();
    Cursor cursor =
        db.query(GoalContract.TABLE, GoalContract.COLUNS, null, null, null, null, GoalContract.ID);
    List<Goal> values = GoalContract.getGoals(cursor);

    db.close();
    dataBaseHelper.close();

    return values;
  }
  public static void delete(long id) {

    DataBaseHelper dataBaseHelper = DataBaseHelper.getIstance();
    SQLiteDatabase db = dataBaseHelper.getWritableDatabase();

    String where = GoalContract.ID + " = ? ";
    String[] params = {String.valueOf(id)};

    db.delete(GoalContract.TABLE, where, params);

    db.close();
    dataBaseHelper.close();
  }
  @Override
  public Cursor query(
      Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    Cursor retCursor;
    String query = "";
    if (selectionArgs != null && selectionArgs.length > 0) {
      query =
          "SELECT "
              + projection[0]
              + " FROM "
              + MoviesCPConstants.FAVOURITES_TABLE_NAME
              + " WHERE "
              + MoviesParser.TAG_ID
              + " = "
              + selectionArgs[0];
      Log.d("movies_query", query);
    }
    switch (uriMatcher.match(uri)) {
      case MOVIES:
        retCursor =
            mOpenHelper
                .getReadableDatabase()
                .query(
                    MoviesCPConstants.FAVOURITES_TABLE_NAME,
                    projection,
                    selection,
                    selectionArgs,
                    null,
                    null,
                    sortOrder);
        return retCursor;

      case MOVIES_ID:
        retCursor =
            mOpenHelper
                .getReadableDatabase()
                .query(
                    MoviesCPConstants.FAVOURITES_TABLE_NAME,
                    projection,
                    selection,
                    selectionArgs,
                    null,
                    null,
                    sortOrder);
        return retCursor;
      default:
        throw new IllegalArgumentException("Unknown URI " + uri);
    }
  }
  @Override
  public long readIndexedField() throws SQLException {
    long start = System.nanoTime();
    Cursor c = null;
    try {
      SQLiteDatabase db = mHelper.getReadableDatabase();
      String selection = Message.COMMAND_ID + "=?";
      String[] selectionArgs = new String[] {String.valueOf(LOOK_BY_INDEXED_FIELD)};
      c =
          db.query(
              Message.TABLE_NAME, Message.PROJECTION, selection, selectionArgs, null, null, null);

      if (c != null && c.moveToFirst()) {
        Message newMessage = new Message();
        newMessage.setChannelId(c.getLong(c.getColumnIndex(Message.CHANNEL_ID)));
        newMessage.setClientId(c.getLong(c.getColumnIndex(Message.CLIENT_ID)));
        newMessage.setCommandId(c.getLong(c.getColumnIndex(Message.COMMAND_ID)));
        newMessage.setContent(c.getString(c.getColumnIndex(Message.CONTENT)));
        newMessage.setCreatedAt(c.getInt(c.getColumnIndex(Message.CREATED_AT)));
        newMessage.setSenderId(c.getLong(c.getColumnIndex(Message.SENDER_ID)));
        newMessage.setSortedBy(c.getDouble(c.getColumnIndex(Message.SORTED_BY)));

        Log.d(SQLiteExecutor.class.getSimpleName(), "Read, " + c.getCount() + " rows");
      }
    } finally {
      if (c != null) {
        c.close();
      }
    }
    return System.nanoTime() - start;
  }
  @Override
  public long readWholeData() throws SQLException {
    long start = System.nanoTime();
    Cursor c = null;
    try {
      SQLiteDatabase db = mHelper.getReadableDatabase();
      List<Message> messages = new LinkedList<Message>();
      c = db.query(Message.TABLE_NAME, Message.PROJECTION, null, null, null, null, null);

      while (c != null && c.moveToNext()) {

        Message newMessage = new Message();
        newMessage.setChannelId(c.getLong(c.getColumnIndex(Message.CHANNEL_ID)));
        newMessage.setClientId(c.getLong(c.getColumnIndex(Message.CLIENT_ID)));
        newMessage.setCommandId(c.getLong(c.getColumnIndex(Message.COMMAND_ID)));
        newMessage.setContent(c.getString(c.getColumnIndex(Message.CONTENT)));
        newMessage.setCreatedAt(c.getInt(c.getColumnIndex(Message.CREATED_AT)));
        newMessage.setSenderId(c.getLong(c.getColumnIndex(Message.SENDER_ID)));
        newMessage.setSortedBy(c.getDouble(c.getColumnIndex(Message.SORTED_BY)));

        messages.add(newMessage);
      }
      Log.d(SQLiteExecutor.class.getSimpleName(), "Read, " + messages.size() + " rows");
    } finally {
      if (c != null) {
        c.close();
      }
    }
    return System.nanoTime() - start;
  }
  public static List<Email> getAllByContact(Long idcontact) {
    DataBaseHelper dataBaseHelper = DataBaseHelper.getIstance();
    SQLiteDatabase db = dataBaseHelper.getReadableDatabase();

    String where = EmailContract.CONTACTID + " = ? ";
    String[] params = {idcontact.toString()};
    Cursor cursor =
        db.query(
            EmailContract.TABLE, EmailContract.COLUNS, where, params, null, null, EmailContract.ID);
    List<Email> values = EmailContract.getEmails(cursor);

    db.close();
    dataBaseHelper.close();

    return values;
  }
  @Override
  public Uri insert(Uri uri, ContentValues values) {
    final SQLiteDatabase db = mOpenHelper.getWritableDatabase();

    Uri returnURI;
    switch (uriMatcher.match(uri)) {
      case MOVIES:
        {
          long _id = db.insert(MoviesCPConstants.FAVOURITES_TABLE_NAME, null, values);
          if (_id > 0) {
            returnURI = MoviesCPConstants.buildMoviesUri(_id);
          } else {
            throw new SQLException("Failed to insert row into: " + uri);
          }
          break;
        }

      default:
        {
          throw new UnsupportedOperationException("Unknown uri: " + uri);
        }
    }

    getContext().getContentResolver().notifyChange(uri, null);
    return returnURI;
  }
  public void sendmail() {

    try {

      SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);

      request.addProperty("UserLogin", insstrrec);
      request.addProperty("recipient", onlyname);
      request.addProperty("sender", insstrsend);
      request.addProperty("TimeStamp", curtimestamp);
      request.addProperty("Attachment", insstratt);
      request.addProperty("Title", insstrtitle);
      request.addProperty("Body", insstrbody);
      request.addProperty("FolderId", "0");
      request.addProperty("Viewed", "0");
      request.addProperty("Priority", "0");

      SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

      envelope.setOutputSoapObject(request);
      envelope.dotNet = true;
      envelope.encodingStyle = SoapSerializationEnvelope.XSD;
      HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

      androidHttpTransport.call(SOAP_ACTION1, envelope);
      Toast.makeText(mailbox.this, "Mail send successfully!!!!!!!", Toast.LENGTH_SHORT).show();

      data.updatemail(insmid, onlyname);

    } catch (Exception e) {
      // text1.setText(e.getMessage());
      System.out.println("Error msg:" + e.getMessage());
    }
  }
Example #24
0
 public void update(String id_config, String base_server) {
   SQLiteDatabase db = dbh.getWritableDatabase();
   ContentValues datas = new ContentValues();
   datas.put("base_server", base_server);
   db.update(SpyConfig.SPY_CONFIG_TABLE, datas, "id_config=" + id_config, null);
   Log.i(SpyConfig.SPY_LOGGING, "UPDATE DATA");
 }
 // method to delete a Record of UserName
 public int deleteuri() {
   db = dbHelper.getReadableDatabase();
   int numberOFEntriesDeleted = db.delete(photourl.TABLE_NAME, null, null);
   // Toast.makeText(context, "Number of key Deleted Successfully : "+numberOFEntriesDeleted,
   // Toast.LENGTH_LONG).show();
   return numberOFEntriesDeleted;
 }
  public void insertmail() {

    Cursor c1 = data.selectmailboxto(onlyname);

    while (c1.moveToNext()) {
      insmid = c1.getInt(0);
      insstruserlogin = c1.getString(1);
      insstrrec = c1.getString(2);
      insstrsend = c1.getString(3);
      insstrdt = c1.getString(4);
      insstratt = c1.getString(5);
      insstrtitle = c1.getString(6);
      insstrbody = c1.getString(7);

      System.out.println("Id:" + insmid);
      System.out.println("Login name:" + insstruserlogin);
      System.out.println("Reciever:" + insstrrec);
      System.out.println("Sender:" + insstrsend);
      System.out.println("Date:" + insstrdt);
      System.out.println("Attachment:" + insstratt);
      System.out.println("Subject:" + insstrtitle);
      System.out.println("Body:" + insstrbody);
      sendmail();
    }
  }
  @Override
  public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
    int count = 0;
    final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    switch (uriMatcher.match(uri)) {
      case MOVIES:
        count =
            db.update(MoviesCPConstants.FAVOURITES_TABLE_NAME, values, selection, selectionArgs);
        break;

      case MOVIES_ID:
        count =
            db.update(
                MoviesCPConstants.FAVOURITES_TABLE_NAME,
                values,
                MoviesParser.TAG_ID
                    + " = "
                    + uri.getPathSegments().get(1)
                    + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""),
                selectionArgs);
        break;

      default:
        throw new IllegalArgumentException("Unknown URI " + uri);
    }
    getContext().getContentResolver().notifyChange(uri, null);
    return count;
  }
Example #28
0
  /**
   * Retrieves all the team members saved in the database
   *
   * @return List with all the team members
   */
  public List<TeamMember> getTeamMembers() {
    Debug.logDebug("Loading data from database");
    SQLiteDatabase db = mDbHelper.getReadableDatabase();

    Cursor teamMembersCursor = db.rawQuery(SQL_SELECT_ALL, null);
    return Mapper.mapTeamMembers(teamMembersCursor);
  }
Example #29
0
 public void add(String base_server) {
   SQLiteDatabase db = dbh.getWritableDatabase();
   ContentValues datas = new ContentValues();
   datas.put("base_server", base_server);
   db.insertOrThrow(SpyConfig.SPY_CONFIG_TABLE, null, datas);
   Log.i(SpyConfig.SPY_LOGGING, "INSERT DATA");
 }
  public void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.deletelist);
    data = new DataBaseHelper(this);
    lv1 = (ListView) findViewById(R.id.List);
    bback = (Button) findViewById(R.id.back);
    bback.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            call();
          }
        });

    Bundle bundle = getIntent().getExtras();
    String name2 = bundle.getString("name1");
    Cursor c1 = data.getDataCallid(name2);
    while (c1.moveToNext()) {
      id1 = c1.getInt(0);
      System.out.println("IDs " + id1);
    }
    Cursor c = data.getDataCallList(id1);
    System.out.println("ID1 " + id1);
    while (c.moveToNext()) {

      n2 = c.getString(0);
      n3 = c.getString(1);
      results.add(n2 + "  " + n3);
      System.out.println("FName" + n2);
      System.out.println("LName" + n3);
      oname = n2 + n3;
    }
    Cursor c2 = data.getCallListid(n2, n3);
    while (c2.moveToNext()) {
      id2 = c2.getInt(0);
      System.out.println("IDs " + id2);
    }
    CheckBox cb = new CheckBox(this);
    lv1.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    lv1.setAdapter(
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, results));
    lv1.setTextFilterEnabled(true);
    lv1.setOnItemClickListener(this);
  }