List of usage examples for android.content ContentValues ContentValues
public ContentValues()
From source file:Main.java
public static void singleBroadcast(Context context, String filepath) { final int DIR_FORMAT = 0x3001; // directory Uri MediaUri = MediaStore.Files.getContentUri("external"); ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, filepath); values.put("format", DIR_FORMAT); values.put(MediaStore.MediaColumns.DATE_MODIFIED, System.currentTimeMillis() / 1000); context.getContentResolver().insert(MediaUri, values); }
From source file:Main.java
/** * Adds the saved image to the gallery//from w ww . ja v a 2 s .c o m * * From: http://stackoverflow.com/a/20859733 * @param filePath * @param context */ public static void addImageToGallery(final String filePath, final Context context) { ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis()); values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); values.put(MediaStore.MediaColumns.DATA, filePath); context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); }
From source file:Main.java
private static void insertDisease(SQLiteDatabase db, String diseaseName, String diseaseSymptoms, String diseaseOverview, String diseaseExpectations, String diseaseRiskFactors, String diseaseTreatment, String diseaseSelfCare, String diseaseMAdeWorseBy) { ContentValues diseaseValues = new ContentValues(); diseaseValues.put("NAME", diseaseName); diseaseValues.put("SYMPTOMS", diseaseSymptoms); diseaseValues.put("OVERVIEW", diseaseOverview); diseaseValues.put("EXPECTATIONS", diseaseExpectations); diseaseValues.put("RISKFACTORS", diseaseRiskFactors); diseaseValues.put("TREATMENT", diseaseTreatment); diseaseValues.put("SELFCARE", diseaseSelfCare); diseaseValues.put("MADEWORSEBY", diseaseMAdeWorseBy); db.insert("DISEASE", null, diseaseValues); }
From source file:Main.java
public static void insertPlaceholderCall(ContentResolver contentResolver, String name, String number) { ContentValues values = new ContentValues(); values.put(CallLog.Calls.NUMBER, number); values.put(CallLog.Calls.DATE, System.currentTimeMillis()); values.put(CallLog.Calls.DURATION, 0); values.put(CallLog.Calls.TYPE, CallLog.Calls.OUTGOING_TYPE); values.put(CallLog.Calls.NEW, 1);/*w w w .ja v a 2 s .com*/ values.put(CallLog.Calls.CACHED_NAME, name); values.put(CallLog.Calls.CACHED_NUMBER_TYPE, 0); values.put(CallLog.Calls.CACHED_NUMBER_LABEL, ""); Log.d("Call Log", "Inserting call log placeholder for " + number); contentResolver.insert(CallLog.Calls.CONTENT_URI, values); }
From source file:Main.java
public static int updateItemsFromStateToState(SQLiteDatabase database, Integer original_state, Integer new_state) { String where_clause = COLUMN_STATE + " = " + original_state; ContentValues values = new ContentValues(); values.put(COLUMN_STATE, new_state); int affected = database.update(TABLE_NAME, values, where_clause, null); return affected; }
From source file:Main.java
public static void insertStudent(final SQLiteDatabase database, final String id, final String name) { final ContentValues courseValues; courseValues = new ContentValues(); courseValues.put(STUDENT_NUMBER, id); courseValues.put(STUDENT_NAME, name); database.insert(STUDENT_TABLE, null, courseValues); }
From source file:Main.java
public static void insertStudentCourse(final SQLiteDatabase database, final String id, final String courseName) { final ContentValues courseValues; courseValues = new ContentValues(); courseValues.put(STUDENT_NUMBER, id); courseValues.put(COURSE_NAME, courseName); database.insert(STU_COUR_TABLE, null, courseValues); }
From source file:Main.java
private static void insertDrink(SQLiteDatabase db, String name, String description, int imageResourceId) { ContentValues drinkValues = new ContentValues(); drinkValues.put(COLUMN_NAME, name);//from w w w . j a va 2 s .c o m drinkValues.put(COLUMN_DESCRIPTION, description); drinkValues.put(COLUMN_IMAGE_RESOURCE_ID, imageResourceId); db.insert(TABLE_DRINK, null, drinkValues); }
From source file:Main.java
/********************************************************************************************** * * Helper method to insert items into the individual muscle group tables of the database * *********************************************************************************************/ private static void insertLift(SQLiteDatabase db, String name, String description, String searchLink, String image_id, String muscleGroup) { ContentValues lift = new ContentValues(); lift.put("NAME", name); lift.put("DESCRIPTION", description); lift.put("SEARCH_LINK", searchLink); lift.put("IMAGE_RESOURCE_ID", image_id); db.insert(muscleGroup, null, lift);//from w ww .j av a2 s . c o m }
From source file:Main.java
public static void openCamera(Context context, int code) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new ContentValues())); // intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment.getExternalStorageDirectory() + imagePath))); ((Activity) context).startActivityForResult(intent, code); } else/*from w w w .j a v a2 s. c om*/ Toast.makeText(context, "no sdcard!", Toast.LENGTH_SHORT).show(); }