public static string GetRealPathFromURI(Android.Net.Uri contentUri) { var mediaStoreImagesMediaData = "_data"; string[] projection = { mediaStoreImagesMediaData }; Android.Database.ICursor cursor = Application.Context.ContentResolver.Query(contentUri, projection, null, null, null); int columnIndex = cursor.GetColumnIndexOrThrow(mediaStoreImagesMediaData); cursor.MoveToFirst(); return(cursor.GetString(columnIndex)); //ContentResolver cr = Application.Context.ContentResolver; //Android.Net.Uri uri = MediaStore.Files.GetContentUri("external"); //// every column, although that is huge waste, you probably need //// BaseColumns.DATA (the path) only. //String[] projection = null; //// exclude media files, they would be here also. //String selection = MediaStore.Files.FileColumns.MediaType + "=" // + Android.po; //String[] selectionArgs = null; // there is no ? in selection so null here //String sortOrder = null; // unordered //Cursor allNonMediaFiles = cr.query(uri, projection, selection, selectionArgs, sortOrder); }
public List <Question> getAllQuestions() { List <Question> quesList = new List <Question>(); // Select All Query string selectQuery = "SELECT * FROM " + TABLE_QUEST; dbase = this.ReadableDatabase; Cursor cursor = dbase.RawQuery(selectQuery, null); // looping through all rows and adding to list if (cursor.MoveToFirst()) { do { Question quest = new Question(); quest.setID(cursor.GetInt(0)); quest.setQUESTION(cursor.GetString(1)); quest.setANSWER(cursor.GetString(2)); quest.setOPTA(cursor.GetString(3)); quest.setOPTB(cursor.GetString(4)); quest.setOPTC(cursor.GetString(5)); quesList.Add(quest); } while (cursor.MoveToNext()); } // return quest list return(quesList); }
public int rowcount() { int row = 0; string selectQuery = "SELECT * FROM " + TABLE_QUEST; SQLiteDatabase db = this.WritableDatabase; Cursor cursor = db.RawQuery(selectQuery, null); row = cursor.Count; return(row); }
public override View NewView(Context context, Android.Database.ICursor cursor, ViewGroup parent) { LayoutInflater inflater = LayoutInflater.From(context); TextView view = (TextView)inflater.Inflate( Android.Resource.Layout.SimpleDropDownItem1Line, parent, false); view.Text = cursor.GetString(COLUMN_DISPLAY_NAME); return(view); }
public String getRealPathFromURI(Android.Net.Uri contentUri) { var mediaStoreImagesMediaData = "_data"; string[] projection = { mediaStoreImagesMediaData }; Android.Database.ICursor cursor = this.ContentResolver.Query(contentUri, projection, null, null, null); int columnIndex = cursor.GetColumnIndexOrThrow(mediaStoreImagesMediaData); cursor.MoveToFirst(); return(cursor.GetString(columnIndex)); }
public void OnQueryComplete(int token, Java.Lang.Object cookie, Android.Database.ICursor cursor) { Console.WriteLine("OnQueryComplete!"); if (Activity == null) { return; } Console.WriteLine("Is Sessions? = " + TracksFragment.NEXT_TYPE_SESSIONS.Equals(mNextType)); Activity.StartManagingCursor(cursor); mAdapter.SetHasAllItem(true); mAdapter.SetIsSessions(TracksFragment.NEXT_TYPE_SESSIONS.Equals(mNextType)); mAdapter.ChangeCursor(cursor); }
public bool SetViewValue(View view, Android.Database.ICursor cursor, int columnIndex) { if (columnIndex == 2) { long ms = cursor.GetLong(columnIndex); DateTime date = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(ms).ToLocalTime(); TextView textView = (TextView)view; textView.Text = date.ToLongDateString(); return(true); } return(false); }
public List <EntCallLog> getCallLog(string queryFilter, string querySorter) { //string queryFilter = System.String.Format("{0}={1}", log.Calls.Date, dt.Ticks); // string querySorter = System.String.Format("{0} desc limit 100 ", log.Calls.Date); Android.Database.ICursor queryData = Application.Context.ContentResolver.Query(log.Calls.ContentUri, null, queryFilter, null, querySorter); List <EntCallLog> lstRecentCalls = new List <EntCallLog>(); while (queryData.MoveToNext()) { EntCallLog ent = new EntCallLog(); ent.numero = queryData.GetString(queryData.GetColumnIndex(log.Calls.Number)); ent.tipo = (Android.Provider.CallType)queryData.GetInt(queryData.GetColumnIndex(log.Calls.Type)); ent.nombre = queryData.GetString(queryData.GetColumnIndex(log.Calls.CachedName)); ent.duracion = queryData.GetInt(queryData.GetColumnIndex(log.Calls.Duration)); ent.fecha = DateTime.Parse(new Java.Sql.Date(queryData.GetLong(queryData.GetColumnIndex(log.Calls.Date))).ToString()); ent.imageUri = queryData.GetString(queryData.GetColumnIndex(log.Calls.CachedPhotoUri)); lstRecentCalls.Add(ent); } return(lstRecentCalls); }
public void OnQueryComplete(int token, Java.Lang.Object cookie, Android.Database.ICursor cursor) { if (Activity == null) { return; } if (token == SessionsQuery._TOKEN || token == SearchQuery._TOKEN) { OnSessionOrSearchQueryComplete(cursor); } else if (token == TracksQuery._TOKEN) { OnTrackQueryComplete(cursor); } else { Log.Debug("SessionsFragment/onQueryComplete", "Query complete, Not Actionable: " + token); cursor.Close(); } }
public override void BindView(View view, Context context, Android.Database.ICursor cursor) { ((TextView)view).Text = cursor.GetString(COLUMN_DISPLAY_NAME); }