List of usage examples for android.database.sqlite SQLiteDatabase insert
public long insert(String table, String nullColumnHack, ContentValues values)
From source file:com.concentricsky.android.khanacademy.data.remote.LibraryUpdaterTask.java
private void insertTopic(SQLiteDatabase tempDb, ContentValues values) { tempDb.insert(topicTableName, null, values); }
From source file:com.seneca.android.senfitbeta.DbHelper.java
public void insertImg(int id, String link) { Log.d("INSERT IMGDB", "Inserting images..."); SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(IMG_ID, id);//from w ww .j a v a 2s.co m values.put(LINK, link); long info = db.insert(RIP_TABLE, null, values); }
From source file:com.seneca.android.senfitbeta.DbHelper.java
public void insertMuscles(int id, String name) { Log.d("INSERT DB", "Inserting muscles..."); SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(RIP_ID, id);/*from w w w.ja v a 2 s. c om*/ values.put(RIP_NAME, name); long info = db.insert(RIP_TABLE, null, values); }
From source file:com.seneca.android.senfitbeta.DbHelper.java
public void addUsers(String email, String password) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(COLUMN_EMAIL, email);//from ww w .j av a 2s . c o m values.put(COLUMN_PASS, password); long id = db.insert(USER_TABLE, null, values); db.close(); }
From source file:com.google.zxing.client.android.history.HistoryManager.java
public void addHistoryItem(Result result, ResultHandler handler, String data) { // Do not save this item to the history if the preference is turned off, // or the contents are // considered secure. if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) || handler.areContentsSecure()) { return;/*from www . j a va 2s. c o m*/ } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) { deletePrevious(result.getText()); } ContentValues values = new ContentValues(); values.put(DBHelper.TEXT_COL, result.getText()); values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString()); values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString()); values.put(DBHelper.TIMESTAMP_COL, data.toString()); SQLiteOpenHelper helper = new DBHelper(activity); SQLiteDatabase db = null; try { db = helper.getWritableDatabase(); // Insert the new entry into the DB. db.insert(DBHelper.TABLE_NAME, null, values); } finally { close(null, db); } }
From source file:net.olejon.spotcommander.AddComputerActivity.java
private void addComputer() { final EditText computerNameInput = (EditText) findViewById(R.id.add_computer_name); final EditText computerUriInput = (EditText) findViewById(R.id.add_computer_uri); final EditText computerUsernameInput = (EditText) findViewById(R.id.add_computer_username); final EditText computerPasswordInput = (EditText) findViewById(R.id.add_computer_password); computerNameInput.addTextChangedListener(new TextWatcher() { @Override// w w w . j a va 2 s . c o m public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { mAddComputerNameInputLayout.setError(null); } @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { } }); computerUriInput.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { mAddComputerUriInputLayout.setError(null); } @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { } }); final String computerName = computerNameInput.getText().toString().trim(); final String computerUri = computerUriInput.getText().toString().trim(); final String computerUsername = computerUsernameInput.getText().toString().trim(); final String computerPassword = computerPasswordInput.getText().toString().trim(); final InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(computerNameInput.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY); if (mNetworkScanTask != null && mNetworkScanTask.getStatus() == AsyncTask.Status.RUNNING) { mTools.showToast(getString(R.string.add_computer_scanning_network), 0); } else if (computerName.equals("")) { mAddComputerNameInputLayout.setError(getString(R.string.add_computer_invalid_name)); } else if (!computerUri.matches("^https?://.*")) { mAddComputerUriInputLayout.setError(getString(R.string.add_computer_invalid_uri)); } else { final ContentValues contentValues = new ContentValues(); contentValues.put(MainSQLiteHelper.COLUMN_NAME, computerName); contentValues.put(MainSQLiteHelper.COLUMN_URI, computerUri); contentValues.put(MainSQLiteHelper.COLUMN_USERNAME, computerUsername); contentValues.put(MainSQLiteHelper.COLUMN_PASSWORD, computerPassword); contentValues.put(MainSQLiteHelper.COLUMN_NETWORK_NAME, ""); contentValues.put(MainSQLiteHelper.COLUMN_NETWORK_DEFAULT, 0); final SQLiteDatabase database = new MainSQLiteHelper(mContext).getWritableDatabase(); database.insert(MainSQLiteHelper.TABLE_COMPUTERS, null, contentValues); database.close(); finish(); } }
From source file:com.appsimobile.appsii.module.apps.AppsProvider.java
@Override public int bulkInsert(Uri uri, @NonNull ContentValues[] values) { SqlArguments args = new SqlArguments(uri); SQLiteDatabase db = mOpenHelper.getWritableDatabase(); db.beginTransaction();//from w ww . j a v a2 s . co m try { int numValues = values.length; for (int i = 0; i < numValues; i++) { if (db.insert(args.table, null, values[i]) < 0) return 0; } db.setTransactionSuccessful(); } finally { db.endTransaction(); } sendNotify(uri); return values.length; }
From source file:com.openerp.addons.note.EditNoteFragment.java
public void updateNote(int row_id) { try {/* w ww .j av a 2 s . co m*/ JSONArray tagID = db.getSelectedTagId(selectedTags); long stage_id = Long.parseLong(stages.get(noteStages.getSelectedItem().toString())); ContentValues values = new ContentValues(); JSONObject vals = new JSONObject(); // If Pad Installed Over Server if (padAdded) { JSONArray url = new JSONArray(); url.put(originalMemo); JSONObject obj = oe_obj.call_kw("pad.common", "pad_get_content", url); // HTMLHelper helper = new HTMLHelper(); String link = HTMLHelper.htmlToString(obj.getString("result")); values.put("stage_id", stage_id); vals.put("stage_id", Integer.parseInt(values.get("stage_id").toString())); values.put("name", db.generateName(link)); vals.put("name", values.get("name").toString()); values.put("memo", obj.getString("result")); vals.put("memo", values.get("memo").toString()); values.put("note_pad_url", originalMemo); vals.put("note_pad_url", values.get("note_pad_url").toString()); } // If Pad Not Installed Over Server else { values.put("stage_id", stage_id); vals.put("stage_id", Integer.parseInt(values.get("stage_id").toString())); values.put("name", db.generateName(noteMemo.getText().toString())); vals.put("name", values.get("name").toString()); values.put("memo", Html.toHtml(noteMemo.getText())); vals.put("memo", values.get("memo").toString()); } JSONArray tag_ids = new JSONArray(); tag_ids.put(6); tag_ids.put(false); JSONArray c_ids = new JSONArray(tagID.toString()); tag_ids.put(c_ids); vals.put("tag_ids", new JSONArray("[" + tag_ids.toString() + "]")); // This will update Notes over Server And Local database db = new NoteDBHelper(scope.context()); if (oe_obj.updateValues(db.getModelName(), vals, row_id)) { db.write(db, values, row_id, true); db.executeSQL("delete from note_note_note_tag_rel where note_note_id = ? and oea_name = ?", new String[] { row_id + "", scope.User().getAndroidName() }); for (int i = 0; i < tagID.length(); i++) { ContentValues rel_vals = new ContentValues(); rel_vals.put("note_note_id", row_id); rel_vals.put("note_tag_id", tagID.getInt(i)); rel_vals.put("oea_name", scope.User().getAndroidName()); SQLiteDatabase insertDb = db.getWritableDatabase(); insertDb.insert("note_note_note_tag_rel", null, rel_vals); insertDb.close(); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:net.olejon.mdapp.NotesEditActivity.java
private void saveNote() { String title = mTitleEditText.getText().toString().trim(); String text = mTextEditText.getText().toString().trim(); String patientId = mPatientIdEditText.getText().toString().trim(); String patientName = mPatientNameEditText.getText().toString().trim(); String patientDoctor = mPatientDoctorEditText.getText().toString().trim(); String patientDepartment = mPatientDepartmentEditText.getText().toString().trim(); String patientRoom = mPatientRoomEditText.getText().toString().trim(); if (title.equals("") || text.equals("")) { mTools.showToast(getString(R.string.notes_edit_invalid_values), 1); } else {//w ww.ja va 2 s . com ContentValues contentValues = new ContentValues(); contentValues.put(NotesSQLiteHelper.COLUMN_TITLE, title); contentValues.put(NotesSQLiteHelper.COLUMN_TEXT, text); contentValues.put(NotesSQLiteHelper.COLUMN_DATA, ""); contentValues.put(NotesSQLiteHelper.COLUMN_PATIENT_ID, patientId); contentValues.put(NotesSQLiteHelper.COLUMN_PATIENT_NAME, patientName); contentValues.put(NotesSQLiteHelper.COLUMN_PATIENT_DOCTOR, patientDoctor); contentValues.put(NotesSQLiteHelper.COLUMN_PATIENT_DEPARTMENT, patientDepartment); contentValues.put(NotesSQLiteHelper.COLUMN_PATIENT_ROOM, patientRoom); if (mPatientMedicationsJsonArray.length() == 0) { contentValues.put(NotesSQLiteHelper.COLUMN_PATIENT_MEDICATIONS, ""); } else { contentValues.put(NotesSQLiteHelper.COLUMN_PATIENT_MEDICATIONS, mPatientMedicationsJsonArray.toString()); } SQLiteDatabase sqLiteDatabase = new NotesSQLiteHelper(mContext).getWritableDatabase(); if (noteId == 0) { sqLiteDatabase.insert(NotesSQLiteHelper.TABLE, null, contentValues); } else { sqLiteDatabase.update(NotesSQLiteHelper.TABLE, contentValues, NotesSQLiteHelper.COLUMN_ID + " = " + noteId, null); } sqLiteDatabase.close(); mTools.showToast(getString(R.string.notes_edit_saved), 1); finish(); } }
From source file:org.runnerup.view.MainLayout.java
private void handleHooks(String key) { if (key.contains("_audio_cues.xml")) { String name = key.substring(0, key.indexOf("_audio_cues.xml")); SQLiteDatabase mDB = DBHelper.getWritableDatabase(this); ContentValues tmp = new ContentValues(); tmp.put(DB.AUDIO_SCHEMES.NAME, name); tmp.put(DB.AUDIO_SCHEMES.SORT_ORDER, 0); mDB.insert(DB.AUDIO_SCHEMES.TABLE, null, tmp); DBHelper.closeDB(mDB);/* www. ja v a2s . co m*/ } }