예제 #1
0
            void ShowUriInfos(global::Android.Net.Uri uri, ContentResolver resolver)
            {
                System.Diagnostics.Debug.WriteLine("URI-Scheme/SchemeSpecificPart: " + uri.Scheme + "; " + uri.SchemeSpecificPart);
                try {
                    System.Diagnostics.Debug.WriteLine("GetDocumentId: " + DocumentsContract.GetDocumentId(uri));
                } catch (Exception ex) {
                }
                try {
                    System.Diagnostics.Debug.WriteLine("GetTreeDocumentId: " + DocumentsContract.GetTreeDocumentId(uri));
                } catch (Exception ex) {
                }
                try {
                    System.Diagnostics.Debug.WriteLine("GetRootId: " + DocumentsContract.GetRootId(uri));
                } catch (Exception ex) {
                }
                global::Android.Database.ICursor cursor = resolver.Query(uri, null, null, null, null);
                if (cursor != null)
                {
                    while (cursor.MoveToNext())
                    {
                        for (int i = 0; i < cursor.ColumnCount; i++)
                        {
                            string val = "";
                            switch (cursor.GetType(i))
                            {
                            case global::Android.Database.FieldType.String: val = cursor.GetString(i); break;

                            case global::Android.Database.FieldType.Integer: val = cursor.GetLong(i).ToString(); break; // GetInt() ist hier falsch

                            case global::Android.Database.FieldType.Float: val = cursor.GetFloat(i).ToString(); break;

                            case global::Android.Database.FieldType.Blob: val = "(blob)"; break;

                            case global::Android.Database.FieldType.Null: val = "(null)"; break;
                            }
                            System.Diagnostics.Debug.WriteLine(string.Format("Column={0}; ColumnName={1}; ColumnType={2}: {3}", i, cursor.GetColumnName(i), cursor.GetType(i).ToString(), val));
                        }
                    }
                }
            }