本文整理汇总了C#中Android.Content.ContentValues类的典型用法代码示例。如果您正苦于以下问题:C# ContentValues类的具体用法?C# ContentValues怎么用?C# ContentValues使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentValues类属于Android.Content命名空间,在下文中一共展示了ContentValues类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AddTweet
public long AddTweet(Tweet tweet)
{
var values = new ContentValues ();
values.Put ("Source", tweet.SourceString);
return twtHelp.WritableDatabase.Insert ("Tweet", null, values);
}
开发者ID:bny-mobile,项目名称:RemoteData,代码行数:7,代码来源:TweetCommands.cs
示例2: SharePhoto
private void SharePhoto()
{
var share = new Intent(Intent.ActionSend);
share.SetType("image/jpeg");
var values = new ContentValues();
values.Put(MediaStore.Images.ImageColumns.Title, "title");
values.Put(MediaStore.Images.ImageColumns.MimeType, "image/jpeg");
Uri uri = ContentResolver.Insert(MediaStore.Images.Media.ExternalContentUri, values);
Stream outstream;
try
{
outstream = ContentResolver.OpenOutputStream(uri);
finalBitmap.Compress(Bitmap.CompressFormat.Jpeg, 100, outstream);
outstream.Close();
}
catch (Exception e)
{
}
share.PutExtra(Intent.ExtraStream, uri);
share.PutExtra(Intent.ExtraText, "Sharing some images from android!");
StartActivity(Intent.CreateChooser(share, "Share Image"));
}
开发者ID:nagyist,项目名称:FlashCastPhotoApp-Android,代码行数:27,代码来源:Activity1.cs
示例3: addToSystemCal
public long addToSystemCal(DateTime dstart, String title, String desc, String loc, int calID)
{
ContentResolver contentResolver = Forms.Context.ApplicationContext.ContentResolver;
ContentValues calEvent = new ContentValues();
calEvent.Put(CalendarContract.Events.InterfaceConsts.CalendarId, calID);
calEvent.Put(CalendarContract.Events.InterfaceConsts.Title, title);
double time = dstart.ToUniversalTime ().Subtract (new DateTime (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
DateTime dend = dstart;
dend.AddHours (2);//default 2 hours long
double timeend = dend.ToUniversalTime ().Subtract (new DateTime (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
//Console.WriteLine ("dst " + time + " eventloc: " + loc);
calEvent.Put(CalendarContract.Events.InterfaceConsts.Dtstart, time);
calEvent.Put(CalendarContract.Events.InterfaceConsts.Dtend, timeend);
//CalendarContract.Events.InterfaceConsts.Id
calEvent.Put(CalendarContract.Events.InterfaceConsts.Description, desc);
calEvent.Put(CalendarContract.Events.InterfaceConsts.EventLocation, loc);
calEvent.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, "Australia/Brisbane");//fuck timezones, who even needs them
long newid = getNewEventId ();
calEvent.Put(CalendarContract.Events.InterfaceConsts.Id, newid);
Forms.Context.ApplicationContext.ContentResolver.Insert(CalendarContract.Events.ContentUri, calEvent);
return newid;
//Console.WriteLine ("EVENT ADDED TO PHONE MAYBE");
}
开发者ID:dittopower,项目名称:330-App---Tconnect,代码行数:33,代码来源:Calender.cs
示例4: UpdateProfile
void UpdateProfile ()
{
// write to the profile
var values = new ContentValues ();
values.Put (ContactsContract.Contacts.InterfaceConsts.DisplayName, "John Doe");
ContentResolver.Update (ContactsContract.Profile.ContentRawContactsUri, values, null, null);
// read the profile
var uri = ContactsContract.Profile.ContentUri;
string[] projection = {
ContactsContract.Contacts.InterfaceConsts.DisplayName };
var cursor = ManagedQuery (uri, projection, null, null, null);
if (cursor.MoveToFirst ()) {
Console.WriteLine(cursor.GetString (cursor.GetColumnIndex (projection [0])));
}
// navigate to the profile in the people app
var intent = new Intent (Intent.ActionView, ContactsContract.Profile.ContentUri);
StartActivity (intent);
}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:25,代码来源:Activity1.cs
示例5: OnProgressChanged
public override void OnProgressChanged(WebView view, int newProgress)
{
base.OnProgressChanged(view, newProgress);
_context.SetProgress(newProgress * 100);
if (newProgress == 100)
{
_context.Title = view.Title;
bool soundEnabled = PreferenceManager.GetDefaultSharedPreferences(_context.ApplicationContext).GetBoolean("sounds", false);
if (soundEnabled)
{
_mediaPlayer = MediaPlayer.Create(_context.ApplicationContext, Resource.Raw.inception_horn);
_mediaPlayer.Completion += delegate { _mediaPlayer.Release(); };
_mediaPlayer.Start();
}
// add this page to the history
using (SQLiteDatabase db = _historyDataHelper.WritableDatabase)
{
var values = new ContentValues();
values.Put("Title", view.Title);
values.Put("Url", view.Url);
values.Put("Timestamp", DateTime.Now.Ticks);
db.Insert("history", null, values);
}
}
else
{
_context.Title = _context.ApplicationContext.Resources.GetString(Resource.String.title_loading);
}
}
开发者ID:jorik041,项目名称:Sample-Projects,代码行数:35,代码来源:CustomWebChromeClient.cs
示例6: addGroup
private bool addGroup()
{
bool result = false;
try {
string name = FindViewById<EditText>(Resource.Id.edit_group_name).Text;
string description = FindViewById<EditText>(Resource.Id.edit_group_description).Text;
string icon = FindViewById<EditText>(Resource.Id.edit_group_icon).Text;
if (name.Length == 0 || description.Length == 0/* || icon.length() == 0*/)
{
Toast.MakeText(this, "One or more fields are empty", ToastLength.Short).Show();
return false;
}
ContentValues values = new ContentValues();
values.Put(YastroidOpenHelper.GROUP_NAME, name);
values.Put(YastroidOpenHelper.GROUP_DESCRIPTION, description);
values.Put(YastroidOpenHelper.GROUP_ICON, icon);
database.Insert(YastroidOpenHelper.GROUP_TABLE_NAME, "null", values);
database.Close();
Log.Info("addGroup", name + " group has been added.");
result = true;
} catch (Exception e) {
Log.Error("addGroup", e.Message);
}
Toast.MakeText(this, "Group Added", ToastLength.Short).Show();
return result;
}
开发者ID:decriptor,项目名称:yastroid,代码行数:30,代码来源:GroupAddActivity.cs
示例7: AddAppointment
//android.permission.WRITE_CALENDAR
public void AddAppointment(DateTime startTime, DateTime endTime, String subject, String location, String details, Boolean isAllDay, AppointmentReminder reminder, AppointmentStatus status)
{
ContentValues eventValues = new ContentValues();
eventValues.Put(CalendarContract.Events.InterfaceConsts.CalendarId, 1);
//_calId);
eventValues.Put(CalendarContract.Events.InterfaceConsts.Title, subject);
eventValues.Put(CalendarContract.Events.InterfaceConsts.Description, details);
eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart, startTime.ToUniversalTime().ToString());
// GetDateTimeMS(2011, 12, 15, 10, 0));
eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend, endTime.ToUniversalTime().ToString());
// GetDateTimeMS(2011, 12, 15, 11, 0));
eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, "UTC");
eventValues.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone, "UTC");
eventValues.Put(CalendarContract.Events.InterfaceConsts.Availability, ConvertAppointmentStatus(status));
eventValues.Put(CalendarContract.Events.InterfaceConsts.EventLocation, location);
eventValues.Put(CalendarContract.Events.InterfaceConsts.AllDay, (isAllDay) ? "1" : "0");
eventValues.Put(CalendarContract.Events.InterfaceConsts.HasAlarm, "1");
var eventUri = CalendarConnector.Activity.ContentResolver.Insert(CalendarContract.Events.ContentUri, eventValues);
long eventID = long.Parse(eventUri.LastPathSegment);
ContentValues remindervalues = new ContentValues();
remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.Minutes, ConvertReminder(reminder));
remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.EventId, eventID);
remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.Method, (int)RemindersMethod.Alert);
var reminderURI = CalendarConnector.Activity.ContentResolver.Insert(CalendarContract.Reminders.ContentUri, remindervalues);
}
开发者ID:pedroccrl,项目名称:Xamarin.Plugins-1,代码行数:31,代码来源:CalendarConnector.cs
示例8: UpdateStockItems
public void UpdateStockItems(List<StockDataItem> stockDataItems)
{
var stockItemsCsv = string.Join(",", stockDataItems.Select(i => ((int) i).ToString()).ToArray());
var contentValues = new ContentValues();
contentValues.Put("StockItems", stockItemsCsv);
Db.Update(CONFIG_TABLE_NAME, contentValues, null, null);
}
开发者ID:mgroves,项目名称:MonodroidStockPortfolio,代码行数:7,代码来源:AndroidSqliteConfigRepository.cs
示例9: OnCreate
public override void OnCreate(SQLiteDatabase paramSQLiteDatabase)
{
// Create table "wikinotes"
paramSQLiteDatabase.ExecSQL("CREATE TABLE " + WikiNote.Notes.TABLE_WIKINOTES + " (" + WikiNote.Notes.Id + " INTEGER PRIMARY KEY,"
+ WikiNote.Notes.TITLE + " TEXT COLLATE LOCALIZED NOT NULL,"
+ WikiNote.Notes.BODY + " TEXT,"
+ WikiNote.Notes.CREATED_DATE + " INTEGER,"
+ WikiNote.Notes.MODIFIED_DATE + " INTEGER" + ");");
// Initialize database
ContentValues localContentValues = new ContentValues();
localContentValues.Put(WikiNote.Notes.TITLE, this._context.Resources.GetString(Resource.String.start_page));
localContentValues.Put(WikiNote.Notes.BODY, this._context.Resources.GetString(Resource.String.top_note));
long localLong = DateTime.Now.ToFileTimeUtc();
localContentValues.Put(WikiNote.Notes.CREATED_DATE, localLong);
localContentValues.Put(WikiNote.Notes.MODIFIED_DATE, localLong);
paramSQLiteDatabase.Insert(WikiNote.Notes.TABLE_WIKINOTES, "huh?", localContentValues);
localContentValues.Put(WikiNote.Notes.TITLE, "PageFormatting");
localContentValues.Put(WikiNote.Notes.BODY, this._context.Resources.GetString(Resource.String.page_formatting_note));
localContentValues.Put(WikiNote.Notes.CREATED_DATE, localLong);
localContentValues.Put(WikiNote.Notes.MODIFIED_DATE, localLong);
paramSQLiteDatabase.Insert(WikiNote.Notes.TABLE_WIKINOTES, "huh?", localContentValues);
}
开发者ID:CBSAdvisor,项目名称:cbs-quantum,代码行数:26,代码来源:DatabaseHelper.cs
示例10: PerformAction
public override void PerformAction(View view)
{
try
{
ContentValues eventValues = new ContentValues();
eventValues.Put( CalendarContract.Events.InterfaceConsts.CalendarId,
_calId);
eventValues.Put(CalendarContract.Events.InterfaceConsts.Title,
"Test Event from M4A");
eventValues.Put(CalendarContract.Events.InterfaceConsts.Description,
"This is an event created from Xamarin.Android");
eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart,
GetDateTimeMS(2011, 12, 15, 10, 0));
eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend,
GetDateTimeMS(2011, 12, 15, 11, 0));
var uri = ContentResolver.Insert(CalendarContract.Events.ContentUri,
eventValues);
}
catch (Exception exception)
{
ErrorHandler.Save(exception, MobileTypeEnum.Android, Context);
}
}
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:26,代码来源:AddEventToCalAction.cs
示例11: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
// Create your application here
SetContentView (Resource.Layout.QuestionnaireSummary);
int Ergebnis = Intent.GetIntExtra ("ergebnis", 0);
TextView ErgebnisText = FindViewById<TextView> (Resource.Id.textView3);
ErgebnisText.Text = string.Format ("{0} {1}", Resources.GetText (Resource.String.total_score), Ergebnis);
Button ContinueHome = FindViewById<Button> (Resource.Id.button1);
ContinueHome.Click += delegate {
//create an intent to go to the next screen
Intent intent = new Intent(this, typeof(Home));
intent.SetFlags(ActivityFlags.ClearTop); //remove the history and go back to home screen
StartActivity(intent);
};
//Toast.MakeText (this, string.Format ("{0}", DateTime.Now.ToString("dd.MM.yy HH:mm")), ToastLength.Short).Show();
ContentValues insertValues = new ContentValues();
insertValues.Put("date_time", DateTime.Now.ToString("dd.MM.yy HH:mm"));
insertValues.Put("ergebnis", Ergebnis);
dbRUOK = new RUOKDatabase(this);
dbRUOK.WritableDatabase.Insert ("RUOKData", null, insertValues);
//The following two function were used to understand the usage of SQLite. They are not needed anymore and I just keep them in case I wanna later look back at them.
//InitializeSQLite3(Ergebnis);
//ReadOutDB ();
}
开发者ID:fsoyka,项目名称:RUOK,代码行数:31,代码来源:QuestionnaireSummary.cs
示例12: OnReceive
public override void OnReceive(Context context, Intent intent)
{
PowerManager pm = (PowerManager)context.GetSystemService(Context.PowerService);
PowerManager.WakeLock w1 = pm.NewWakeLock (WakeLockFlags.Full | WakeLockFlags.AcquireCausesWakeup | WakeLockFlags.OnAfterRelease, "NotificationReceiver");
w1.Acquire ();
//Toast.MakeText (context, "Received intent!", ToastLength.Short).Show ();
var nMgr = (NotificationManager)context.GetSystemService (Context.NotificationService);
//var notification = new Notification (Resource.Drawable.Icon, context.Resources.GetString(Resource.String.ReminderTitle));
var notification = new Notification (Resource.Drawable.Icon, context.Resources.GetString(Resource.String.ReminderTitle));
//Clicking the pending intent does not go to the Home Activity Screen, but to the last activity that was active before leaving the app
var pendingIntent = PendingIntent.GetActivity (context, 0, new Intent (context, typeof(Home)), PendingIntentFlags.UpdateCurrent);
//Notification should be language specific
notification.SetLatestEventInfo (context, context.Resources.GetString(Resource.String.ReminderTitle), context.Resources.GetString(Resource.String.InvalidationText), pendingIntent);
notification.Flags |= NotificationFlags.AutoCancel;
nMgr.Notify (0, notification);
// Vibrator vibrator = (Vibrator) context.GetSystemService(Context.VibratorService);
// if (vibrator != null)
// vibrator.Vibrate(400);
//change shared preferences such that the questionnaire button can change its availability
ISharedPreferences sharedPref = context.GetSharedPreferences("com.FSoft.are_u_ok.PREFERENCES",FileCreationMode.Private);
ISharedPreferencesEditor editor = sharedPref.Edit();
editor.PutBoolean("QuestionnaireActive", false );
editor.Commit ();
//insert a line of -1 into some DB values to indicate that the questions have not been answered at the scheduled time
MoodDatabase dbMood = new MoodDatabase(context);
ContentValues insertValues = new ContentValues();
insertValues.Put("date", DateTime.Now.ToString("dd.MM.yy"));
insertValues.Put("time", DateTime.Now.ToString("HH:mm"));
insertValues.Put("mood", -1);
insertValues.Put("people", -1);
insertValues.Put("what", -1);
insertValues.Put("location", -1);
//use the old value of questionFlags
Android.Database.ICursor cursor;
cursor = dbMood.ReadableDatabase.RawQuery("SELECT date, QuestionFlags FROM MoodData WHERE date = '" + DateTime.Now.ToString("dd.MM.yy") + "'", null); // cursor query
int alreadyAsked = 0; //default value: no questions have been asked yet
if (cursor.Count > 0) { //data was already saved today and questions have been asked, so retrieve which ones have been asked
cursor.MoveToLast (); //take the last entry of today
alreadyAsked = cursor.GetInt(cursor.GetColumnIndex("QuestionFlags")); //retrieve value from last entry in db column QuestionFlags
}
insertValues.Put("QuestionFlags", alreadyAsked);
dbMood.WritableDatabase.Insert ("MoodData", null, insertValues);
//set the new alarm
AlarmReceiverQuestionnaire temp = new AlarmReceiverQuestionnaire();
temp.SetAlarm(context);
w1.Release ();
//check these pages for really waking up the device
// http://stackoverflow.com/questions/6864712/android-alarmmanager-not-waking-phone-up
// https://forums.xamarin.com/discussion/7490/alarm-manager
//it's good to use the alarm manager for tasks that should last even days:
// http://stackoverflow.com/questions/14376470/scheduling-recurring-task-in-android/
}
开发者ID:fsoyka,项目名称:RUOK,代码行数:60,代码来源:AlarmReceiverInvalid.cs
示例13: CreateNote
/// <summary>
/// Create a new note using the title and body provided. If the note is
/// successfully created return the new rowId for that note, otherwise return
/// a -1 to indicate failure.
/// </summary>
/// <param name="title">the title of the note</param>
/// <param name="body">the body of the note</param>
/// <returns>rowId or -1 if failed</returns>
public long CreateNote(string title, string body)
{
var initialValues = new ContentValues();
initialValues.Put(KeyTitle, title);
initialValues.Put(KeyBody, body);
return this.db.Insert(DatabaseTable, null, initialValues);
}
开发者ID:rudini,项目名称:monodroid-samples,代码行数:16,代码来源:NotesDbAdapter.cs
示例14: AddNote
public long AddNote(string title, string contents)
{
var values = new ContentValues();
values.Put("Title", title);
values.Put("Contents", contents);
return _helper.WritableDatabase.Insert("Note", null, values);
}
开发者ID:jorik041,项目名称:Sample-Projects,代码行数:8,代码来源:StandardNoteRepository.cs
示例15: putRecord
public void putRecord(long time, String difficulty, Context context)
{
dbHelper = new DBHelper(context);
ContentValues cv = new ContentValues();
SQLiteDatabase db = dbHelper.WritableDatabase;
SQLiteCursor c = (SQLiteCursor)db.Query("records", null, " difficulty = ?", new String[]{difficulty}, null, null, null);
int count = 1;
if (c.MoveToFirst()) {
int idColIndex = c.GetColumnIndex("id");
int timeColIndex = c.GetColumnIndex("time");
int maxDBindex = c.GetInt(idColIndex);
int maxDBtime = c.GetInt(timeColIndex);
count++;
while (c.MoveToNext()) {
if (c.GetInt(timeColIndex) > maxDBtime){
maxDBtime = c.GetInt(timeColIndex);
maxDBindex = c.GetInt(idColIndex);
}
count++;
}
if (count == 6){
if (time < maxDBtime){
db.Delete("records", " id = ?", new String[]{maxDBindex + ""});
} else {
c.Close();
db.Close();
return;
}
}
}
cv.Put("time", time);
cv.Put("difficulty", difficulty);
db.Insert("records", null, cv);
cv.Clear();
SQLiteCursor gc = (SQLiteCursor)db.Query("general", null, "difficulty = ?", new String[]{difficulty}, null, null, null);
gc.MoveToFirst();
int avgTimeColIndex = gc.GetColumnIndex("avgTime");
int gamesCountColIndex = gc.GetColumnIndex("gamesCount");
int avgTime = 0;
int gamesCount = 0;
if (gc.MoveToFirst()){
avgTime = gc.GetInt(avgTimeColIndex);
gamesCount = gc.GetInt(gamesCountColIndex);
}
int newGamesCount = gamesCount + 1;
int newAvgTime = (avgTime * gamesCount / newGamesCount) + (int)(time / newGamesCount);
cv.Put("difficulty", difficulty);
cv.Put("avgTime", newAvgTime);
cv.Put("gamesCount", newGamesCount);
db.Delete("general", " difficulty = ?", new String[]{difficulty});
db.Insert("general", null, cv);
db.Close();
c.Close();
gc.Close();
}
开发者ID:JustLex,项目名称:CourseTask,代码行数:58,代码来源:DatabaseController.cs
示例16: Update
public long Update(String oldBattleTag, String battleTag, String host, Action<AccountFields> action)
{
var db = dbHelper.WritableDatabase;
var values = new ContentValues();
values.Put(AccountsOpenHelper.FIELD_BATTLETAG, battleTag);
values.Put(AccountsOpenHelper.FIELD_HOST, host);
values.Put(AccountsOpenHelper.FIELD_UPDATED, DateTime.Today.ToString(CultureInfo.InvariantCulture));
return db.Update(AccountsOpenHelper.TABLE_NAME, values, AccountsOpenHelper.FIELD_BATTLETAG + "=?", new[] { oldBattleTag });
}
开发者ID:djtms,项目名称:D3-Android-by-ZTn,代码行数:9,代码来源:AccountsDB.cs
示例17: AddScore
public long AddScore(int scoreNumber, DateTime scoreDate, string name)
{
var values = new ContentValues ();
values.Put ("ScoreNumber", scoreNumber);
values.Put ("ScoreDate", scoreDate.ToString ());
values.Put ("PlayerName", name);
return scrHelp.WritableDatabase.Insert ("QuizScore", null, values);
}
开发者ID:bny-mobile,项目名称:QuizData,代码行数:9,代码来源:ScoreCommands.cs
示例18: Insert
public long Insert(String battleTag, String host)
{
var db = dbHelper.WritableDatabase;
var values = new ContentValues();
values.Put(AccountsOpenHelper.FIELD_BATTLETAG, battleTag);
values.Put(AccountsOpenHelper.FIELD_HOST, host);
values.Put(AccountsOpenHelper.FIELD_UPDATED, DateTime.Today.ToString());
return db.Insert(AccountsOpenHelper.TABLE_NAME, null, values);
}
开发者ID:djtms,项目名称:D3-Android-by-ZTn,代码行数:9,代码来源:AccountsDB.cs
示例19: AddScore
public long AddScore(int ScoreNumber, DateTime ScoreDate, double rating, double slope)
{
var values = new ContentValues();
values.Put("ScoreNumber", ScoreNumber);
values.Put("ScoreDate", ScoreDate.ToString());
values.Put("Rating", rating);
values.Put("Slope", slope);
return dbHelp.WritableDatabase.Insert("GolfScore", null, values);
}
开发者ID:evandrojr,项目名称:Leitor,代码行数:10,代码来源:dbCommands.cs
示例20: insert
public void insert(Transaction transaction)
{
ContentValues values = new ContentValues();
values.Put(COLUMN__ID, transaction.orderId);
values.Put(COLUMN_PRODUCT_ID, transaction.productId);
values.Put(COLUMN_STATE, transaction.purchaseState.ToString());
values.Put(COLUMN_PURCHASE_TIME, transaction.purchaseTime);
values.Put(COLUMN_DEVELOPER_PAYLOAD, transaction.developerPayload);
mDb.Replace(TABLE_TRANSACTIONS, null /* nullColumnHack */, values);
}
开发者ID:Ezekoka,项目名称:MonoGame-StarterKits,代码行数:10,代码来源:BillingDB.cs
注:本文中的Android.Content.ContentValues类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论