コード例 #1
0
ファイル: Imagem.cs プロジェクト: GuilhermeLanca/Gotech
 public static string PegarCaminhoRealUri(Android.Net.Uri contentURI, Context contexto)
 {
     try
     {
         Android.Database.ICursor cursor = contexto.ContentResolver.Query(contentURI, null, null, null, null);
         if (cursor != null)
         {
             cursor.MoveToFirst();
             string documentId = cursor.GetString(0);
             documentId = documentId.Split(':')[0];
             cursor.Close();
             cursor = contexto.ContentResolver.Query(Android.Provider.MediaStore.Images.Media.ExternalContentUri,
                                                     null,
                                                     Android.Provider.MediaStore.Images.Media.InterfaceConsts.Id + " = ? ", new[] { documentId },
                                                     null);
             cursor.MoveToFirst();
             string path = cursor.GetString(cursor.GetColumnIndex(Android.Provider.MediaStore.Images.ImageColumns.Data));
             cursor.Close();
             return(path);
         }
         return(contentURI.Path);
     }
     catch (Android.Database.CursorIndexOutOfBoundsException ex)
     {
         throw ex;
     }
 }
コード例 #2
0
        public ModelPaciente GetPacienteById(int id)
        {
            try
            {
                ModelPaciente modelPaciente = new ModelPaciente();
                string        sqldb_query;

                sqldb_query = "SELECT idPaciente, nomePaciente, nomeResponsavel " +
                              "FROM paciente                                    " +
                              "WHERE idPaciente =                               " + id;

                Android.Database.ICursor sqldb_cursor = null;
                sqldb_cursor = sqldb.RawQuery(sqldb_query, null);

                if (sqldb_cursor.MoveToFirst())
                {
                    modelPaciente.IdPaciente      = sqldb_cursor.GetInt(0);
                    modelPaciente.NomePaciente    = sqldb_cursor.GetString(1);
                    modelPaciente.NomeResponsavel = sqldb_cursor.GetString(2);
                }
                return(modelPaciente);
            }
            catch (SQLiteException ex)
            {
                return(null);
            }
        }
コード例 #3
0
        public ModelMedicamento GetMedicamentoById(int id)
        {
            try
            {
                ModelMedicamento modelMedicamento = new ModelMedicamento();
                string           sqldb_query;

                sqldb_query = "SELECT idMedicamento, nomeMedicamento, qtdMedicamento, corMedicamento, horaMedicamento, dataCriacao, idTratamento, isActive, faseTratamento" +
                              "FROM medicamento                                              " +
                              "WHERE idMedicamento =                                          " + id;

                Android.Database.ICursor sqldb_cursor = null;
                sqldb_cursor = sqldb.RawQuery(sqldb_query, null);

                if (sqldb_cursor.MoveToFirst())
                {
                    modelMedicamento.IdMedicamento   = sqldb_cursor.GetInt(0);
                    modelMedicamento.NomeMedicamento = sqldb_cursor.GetString(1);
                    modelMedicamento.QtdMedicamento  = sqldb_cursor.GetInt(2);
                    modelMedicamento.CorMedicamento  = sqldb_cursor.GetString(3);
                    modelMedicamento.HoraMedicamento = sqldb_cursor.GetString(4);
                    modelMedicamento.DataCriacao     = sqldb_cursor.GetString(5);

                    modelMedicamento.Tratamento = dAoTratamento.GetTratamentoById(sqldb_cursor.GetInt(6));

                    //modelMedicamento.IsActive = sqldb_cursor.GetString(7)
                    modelMedicamento.FaseTratamento = sqldb_cursor.GetString(8);
                }
                return(modelMedicamento);
            }
            catch (SQLiteException ex)
            {
                return(null);
            }
        }
コード例 #4
0
        /**
         * Get the value of the data column for this Uri. This is useful for
         * MediaStore Uris, and other file-based ContentProviders.
         *
         * @param context The context.
         * @param uri The Uri to query.
         * @param selection (Optional) Filter used in the query.
         * @param selectionArgs (Optional) Selection arguments used in the query.
         * @return The value of the _data column, which is typically a file path.
         */
        public static String getDataColumn(Context context, Android.Net.Uri uri, String selection,
                                           String[] selectionArgs)
        {
            Android.Database.ICursor cursor = null;
            string column = "_data";

            string[] projection =
            {
                column
            };

            try
            {
                cursor = context.ContentResolver.Query(uri, projection, selection, selectionArgs,
                                                       null);
                if (cursor != null && cursor.MoveToFirst())
                {
                    int column_index = cursor.GetColumnIndexOrThrow(column);
                    return(cursor.GetString(column_index));
                }
            }
            finally
            {
                if (cursor != null)
                {
                    cursor.Close();
                }
            }
            return(null);
        }
コード例 #5
0
        //Procura um registro e retorna um cursor Android.Database.ICursor
        //Mostra os registros de acordo com critérios de pesquisa
        public string GetUserPassword(string username)
        {
            sqldb_mensagem = "N";
            Android.Database.ICursor sqldb_cursor = null;
            try
            {
                sqldb_query = "SELECT Password FROM Users WHERE Username = '******';";
                //sqldb_query = "SELECT * FROM Users";
                sqldb_cursor = sqldb.RawQuery(sqldb_query, null);


                if (!(sqldb_cursor != null))//(sqldb_cursor == null)?
                {
                    sqldb_mensagem = "Registro não encontrado!";
                    return(sqldb_mensagem);
                }
            }
            catch (SQLiteException ex)
            {
                sqldb_mensagem = ex.Message;
                return(sqldb_mensagem);
            }
            sqldb_cursor.MoveToFirst();
            if (sqldb_cursor.Count != 0)
            {
                sqldb_mensagem = sqldb_cursor.GetString(0);
            }

            return(sqldb_mensagem);
        }
コード例 #6
0
 public static string getPath(Context context, Android.Net.Uri uri)
 {
     if ("content".Equals(uri.Scheme))
     {
         string[] projection             = { "_data" };
         Android.Database.ICursor cursor = null;
         try
         {
             cursor = context.ContentResolver.Query(uri, projection, null, null, null);
             int column_index = cursor.GetColumnIndexOrThrow("_data");
             if (cursor.MoveToFirst())
             {
                 return(cursor.GetString(column_index));
             }
         }
         catch (System.Exception e)
         {
             return(e.Message);
         }
     }
     else if ("file".Equals(uri.Scheme))
     {
         return(uri.Path);
     }
     return(null);
 }
コード例 #7
0
        private static string GetDataColumn(Context context, Uri uri, string selection, string[] selectionArgs)
        {
            Android.Database.ICursor cursor = null;
            string column = MediaStore.Images.Media.InterfaceConsts.Data;       // "_data"

            string[] projection = { column };

            try
            {
                cursor = context.ContentResolver.Query(uri, projection, selection, selectionArgs, null);
                if (cursor != null && cursor.MoveToFirst())
                {
                    int column_index = cursor.GetColumnIndexOrThrow(column);
                    return(cursor.GetString(column_index));
                }
            }
            finally
            {
                if (cursor != null)
                {
                    cursor.Close();
                }
            }

            return(null);
        }
コード例 #8
0
ファイル: Database.cs プロジェクト: Macjiji/Shopping-Csharp
        /// <summary>
        ///     Méthode permettant de récupérer le nom d'un item présent en base de données.
        /// </summary>
        /// <returns>Le nom de l'item, null sinon</returns>
        /// <example>
        ///     Méthode de mise en oeuvre :
        ///     <code>
        ///         Database baseDeDonnees = new Database("Shopping");
        ///         baseDeDonnees.GetItemNameWithId(5);
        ///     </code>
        /// </example>
        public string GetItemNameWithId(int idItem)
        {
            string result = null;

            Android.Database.ICursor sqldb_cursor = null;
            try
            {
                sqldb_query  = "SELECT * FROM Items WHERE _id = " + idItem + ";";
                sqldb_cursor = sqldb.RawQuery(sqldb_query, null);
                if (!(sqldb_cursor != null))
                {
                    sqldb_message = "Pas d'item trouvé ! ";
                    sqldb_cursor.Close();
                }
                else
                {
                    sqldb_message = "Item trouvé ! ";
                    sqldb_cursor.MoveToFirst();
                    result = sqldb_cursor.GetString(sqldb_cursor.GetColumnIndex("nom_fr"));
                    sqldb_cursor.Close();
                }
            }
            catch (SQLiteException ex)
            {
                sqldb_message = ex.Message;
            }
            return(result);
        }
コード例 #9
0
ファイル: Database.cs プロジェクト: Macjiji/Shopping-Csharp
        /// <summary>
        ///     Méthode permettant de récupérer tous le nom des items d'une liste de courses présents en base de données.
        /// </summary>
        /// <returns>La liste des noms d'items d'une liste de courses si ils existent, null sinon</returns>
        /// <example>
        ///     Méthode de mise en oeuvre :
        ///     <code>
        ///         Database baseDeDonnees = new Database("Shopping");
        ///         baseDeDonnees.GetPersonnalItemsFromShoppingList(1, 3);
        ///     </code>
        /// </example>
        public List <string> GetPersonnalItemsFromShoppingList(int idList, int idCat)
        {
            List <string> personnalItems = new List <string>();

            Android.Database.ICursor sqldb_cursor = null;
            try
            {
                sqldb_query  = "SELECT * FROM PersonnalShoppingItems WHERE id_list = " + idList + " AND id_cat = " + idCat + ";";
                sqldb_cursor = sqldb.RawQuery(sqldb_query, null);
                if (!(sqldb_cursor != null))
                {
                    sqldb_message  = "Pas d'items trouvés dans la liste de courses ! ";
                    personnalItems = null;
                    sqldb_cursor.Close();
                }
                else
                {
                    sqldb_message = "Items trouvées dans la liste de courses ! ";
                    sqldb_cursor.MoveToFirst();
                    for (int i = 0; i < sqldb_cursor.Count; i++)
                    {
                        personnalItems.Add(GetItemNameWithId(sqldb_cursor.GetInt(sqldb_cursor.GetColumnIndex("id_item"))));
                        sqldb_cursor.MoveToNext();
                    }
                    sqldb_cursor.Close();
                }
            }
            catch (SQLiteException ex)
            {
                sqldb_message = ex.Message;
            }
            return(personnalItems);
        }
コード例 #10
0
        string GetFileNameByUri(Context context, Android.Net.Uri uri)
        {
            string fileName = "unknown";

            Android.Net.Uri filePathUri = uri;

            if (ContentResolver.SchemeContent.Equals(uri.Scheme))
            {
                Android.Database.ICursor cursor = ContentResolver.Query(uri, null, null, null, null);
                if (cursor.MoveToFirst())
                {
                    int column_index = cursor.GetColumnIndexOrThrow("_data");
                    filePathUri = Android.Net.Uri.Parse(cursor.GetString(column_index));
                    fileName    = filePathUri.LastPathSegment.ToString();
                }
            }
            else if (ContentResolver.SchemeFile.Equals(uri.Scheme))
            {
                fileName = filePathUri.LastPathSegment.ToString();
            }
            else
            {
                fileName = fileName + "_" + filePathUri.LastPathSegment;
            }
            return(fileName);
        }
コード例 #11
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (requestCode == PickImageId)
            {
                if ((resultCode == Result.Ok) && (data != null))
                {
                    // Set the filename as the completion of the Task
                    PickImageTaskCompletionSource?.SetResult(data.DataString);
                    Android.Net.Uri          uri  = data.Data;
                    var                      mime = this.ContentResolver.GetType(uri);
                    Android.Database.ICursor cr   = ContentResolver.Query(uri, null, null, null, null);
                    cr.MoveToFirst();
                    var displayName = cr.GetString(cr.GetColumnIndex(OpenableColumns.DisplayName));

                    Stream stream = ContentResolver.OpenInputStream(uri);
                    // Set the Stream as the completion of the Task
                    PickMediaTaskCompletionSource?.SetResult(new Tuple <Stream, string, MGFileType>(stream, displayName,
                                                                                                    mime.Contains("video") ? MGFileType.Video : MGFileType.Photo));
                }
                else
                {
                    PickImageTaskCompletionSource?.SetResult(null);
                }
            }
        }
コード例 #12
0
        /*
         * Reads all SMS messages from inbox and adds those that match the phone number (address) of the
         * confirmation text for Industry Salon Appointments to a List.
         *
         */
        public List <String> readInbox()
        {
            List <String> sms = new List <String>();

            Android.Net.Uri          uriSms = Android.Net.Uri.Parse("content://sms/inbox");
            Android.Database.ICursor cursor = this.ContentResolver.Query(uriSms, new String[] { "_id", "address", "date", "body" }, null, null, null);

            if (cursor.MoveToFirst())
            {
                while (cursor.MoveToNext())
                {
                    String address = cursor.GetString(1);
                    String body    = cursor.GetString(3);
                    //maybe add another check to see what the date is, idk if that would help remove some unnecessary ones
                    if (address.Equals("2244273491"))
                    {
                        sms.Add(body);
                    }

                    //sms.Add("Address=&gt; " + address + "n SMS =&gt; " + body);
                }
            }
            else
            {
                // no sms found
            }
            return(sms);
        }
コード例 #13
0
        public ModelTratamento GetTratamentoById(int id)
        {
            try
            {
                ModelTratamento modelTratamento = new ModelTratamento();
                string          sqldb_query;

                sqldb_query = "SELECT idTratamento, dataInicio, dataTermino, faseTratamento " +
                              "FROM tratamento                                              " +
                              "WHERE idTratamento =                                         " + id;

                Android.Database.ICursor sqldb_cursor = null;
                sqldb_cursor = sqldb.RawQuery(sqldb_query, null);

                if (sqldb_cursor.MoveToFirst())
                {
                    modelTratamento.IdTratamento   = sqldb_cursor.GetInt(0);
                    modelTratamento.DataInicio     = sqldb_cursor.GetString(1);
                    modelTratamento.DataTermino    = sqldb_cursor.GetString(2);
                    modelTratamento.FaseTratamento = sqldb_cursor.GetString(3);
                }
                return(modelTratamento);
            }
            catch (SQLiteException ex)
            {
                return(null);
            }
        }
コード例 #14
0
        private List <ListaCategoriaProduto> carregProduto()
        {
            Android.Database.ICursor     sql_cursor      = null;
            List <ListaCategoriaProduto> lsItemCategoria = new List <ListaCategoriaProduto> ();

            //percorrendo o retorno do select pelo getrecordcursor e retornando um objeto listacategoriaproduto
            sql_cursor = sqldb.GetRecordCursor(MainActivity.id_categoria);
            //sql_cursor = sqldb.GetRecordCursor ();

            if (sql_cursor != null)
            {
                sql_cursor.MoveToFirst();

                while (sql_cursor.Position < sql_cursor.Count)
                {
                    lsItemCategoria.Add(insItemCategoria(
                                            sql_cursor.GetInt(0),                 //id_categoria
                                            sql_cursor.GetInt(1),                 //cod_produto
                                            sql_cursor.GetString(2).ToString(),   //descricao produto
                                            sql_cursor.GetString(3).ToString(),   //ativo
                                            sql_cursor.GetString(4).ToString(),   //descricao dos itens que compoe o produto
                                            sql_cursor.GetString(5).ToString())); //preco unitario

                    sql_cursor.MoveToNext();
                }
            }

            return(lsItemCategoria);
        }
コード例 #15
0
        protected string GetPathToImage(Android.Net.Uri uri)
        {
            string path = "";

            Android.Database.ICursor cursor = Activity.ContentResolver.Query(uri, null, null, null, null);
            cursor.MoveToFirst();
            string document_id = cursor.GetString(0);

            document_id = document_id.Substring(document_id.LastIndexOf(":") + 1);

            cursor = Activity.ContentResolver.Query(MediaStore.Images.Media.ExternalContentUri,
                                                    null, MediaStore.Images.Media.InterfaceConsts.Id + " = ? ", new string[] { document_id }, null);
            cursor.MoveToFirst();
            path = cursor.GetString(cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.Data));
            cursor.Dispose();

            return(path);
        }
コード例 #16
0
        public void AdicionaItem()
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.SetTitle("CONFIRMAÇÃO");
            builder.SetIcon(Android.Resource.Drawable.IcDialogAlert);
            builder.SetMessage("Oi ! Você confirma enviar este item para seu carrinho?");
            builder.SetPositiveButton("Sim", delegate {
                sql_cursor = sqldb_carrinhoItem.GetRecordCursor("select MAX(_itemPedido) + 1 as ITEM from CARRINHO_ITEM " +
                                                                " where _codEmpresa = '" + MainActivity.iCodEmpresa +
                                                                "' and _codpedido = '" + MainActivity.iCodPedido + "'");

                if (sql_cursor.Count > 0)
                {
                    sql_cursor.MoveToFirst();

                    int iItem;

                    if (sql_cursor.GetInt(0) == 0)
                    {
                        iItem = sql_cursor.GetInt(0) + 1;
                    }
                    else
                    {
                        iItem = sql_cursor.GetInt(0);
                    }

                    sqldb_carrinhoItem.AddRecord(MainActivity.iCodEmpresa,
                                                 MainActivity.iCodPedido,
                                                 iItem,
                                                 MainActivity.id_item_categorira,
                                                 iQtde,
                                                 Convert.ToString(iPrecoUnitario),
                                                 MainActivity.sIMEI,
                                                 MainActivity.sNumCelular,
                                                 txtLembrete.Text,
                                                 "N");

                    if (sqldb_carrinhoItem.Message == "OK")
                    {
                        Toast.MakeText(this, "Adicionado com sucesso!", ToastLength.Short).Show();
                        Thread.Sleep(500);
                        Toast.MakeText(this, "Continue comprando, acesso o icone do Menu!", ToastLength.Short).Show();

                        Finish();
                        StartActivity(typeof(Carrinho));
                    }
                    else
                    {
                        Toast.MakeText(this, "Erro ao adicionar!", ToastLength.Short).Show();
                    }
                }
            });

            builder.SetNegativeButton("Não", delegate { });
            //builder.SetCancelable(false);
            builder.Show();
        }
コード例 #17
0
ファイル: MainActivity.cs プロジェクト: omardacca/Altaaref
        private string GetRealPathFromUri(Android.Net.Uri contentUri)
        {
            Android.Database.ICursor cursor = ContentResolver.Query(contentUri, null, null, null, null);
            cursor.MoveToFirst();
            string docId = cursor.GetString(0);

            docId = docId.Substring(docId.LastIndexOf(":") + 1);
            cursor.Close();

            cursor = ContentResolver.Query(Android.Provider.MediaStore.Images.Media.ExternalContentUri, null,
                                           Android.Provider.MediaStore.Images.Media.InterfaceConsts.Id + " = ? ", new String[] { docId }, null);

            cursor.MoveToFirst();

            string path = cursor.GetString(cursor.GetColumnIndex(Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data));

            cursor.Close();

            return(path);
        }
コード例 #18
0
        public static String getPath(Context context, Android.Net.Uri uri) //throws URISyntaxException
        {
            var mediaStoreImagesMediaData = "_data";

            string[] projection             = { mediaStoreImagesMediaData };
            Android.Database.ICursor cursor = Application.Context.ContentResolver.Query(uri, projection, null, null, null);
            int columnIndex = cursor.GetColumnIndexOrThrow(mediaStoreImagesMediaData);

            cursor.MoveToFirst();
            return(cursor.GetString(columnIndex));
        }
コード例 #19
0
ファイル: EditCardActivity.cs プロジェクト: Lissov/BonusCards
        public string GetRealPathFromURI(Android.Net.Uri contentUri)
        {
            var mediaStoreImagesMediaData = "_data";

            string[] projection             = { mediaStoreImagesMediaData };
            Android.Database.ICursor cursor = this.ManagedQuery(contentUri, projection,
                                                                null, null, null);
            int columnIndex = cursor.GetColumnIndexOrThrow(mediaStoreImagesMediaData);

            cursor.MoveToFirst();
            return(cursor.GetString(columnIndex));
        }
コード例 #20
0
        public Dictionary <string, string> GetSendStatus()
        {
            var db  = helper.ReadableDatabase;
            var dic = new Dictionary <string, string>();

            Android.Database.ICursor cursor = db.Query("sendstatus", null, null, null, null, null, null);
            if (cursor.MoveToFirst())
            {
                dic.Add("servicestatus", cursor.GetString(cursor.GetColumnIndex("servicestatus")));
                dic.Add("sendsuccess", cursor.GetString(cursor.GetColumnIndex("sendsuccess")));
                dic.Add("sendfailure", cursor.GetString(cursor.GetColumnIndex("sendfailure")));
            }
            ;
            db.Dispose();
            return(dic);
        }
コード例 #21
0
        /// <summary>
        /// Select a contact
        /// </summary>
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            if (requestCode == 101 && resultCode == Result.Ok)
            {
                if (data == null || data.Data == null)
                {
                    return;
                }
                string id = data.Data.PathSegments[1];
                if (string.IsNullOrEmpty(id))
                {
                    return;
                }

                _selectedContact = new Contact();

                using (Android.Database.ICursor cursor = ContentResolver.Query(data.Data, null, null, null, null))
                {
                    if (cursor.MoveToFirst())
                    {
                        _selectedContact.DisplayName = cursor.GetString(cursor.GetColumnIndex(Android.Provider.ContactsContract.PhoneLookup.InterfaceConsts.DisplayName));
                        _selectedContact.Email       = cursor.GetString(cursor.GetColumnIndex(Android.Provider.ContactsContract.CommonDataKinds.Email.Address));
                    }
                    else
                    {
                        Toast.MakeText(ApplicationContext, Resource.String.alert_noEmailFound, ToastLength.Short).Show();
                    }
                }

                if (App.Locator.Alert.LsRecipients.Where(el => el.Email == _selectedContact.Email).FirstOrDefault() == null)
                {
                    if (App.Locator.Alert.LsRecipients.Count >= 3)
                    {
                        var errorMessage = Resources.GetString(Resource.String.alert_moreThanThreeRecipients);
                        Toast.MakeText(ApplicationContext, errorMessage, ToastLength.Short).Show();
                    }
                    else
                    {
                        AlertRecipientLayout.AddChild(_selectedContact);
                        App.Locator.Alert.LsRecipients.Add(new AlertRecipientDTO {
                            DisplayName = _selectedContact.DisplayName, Email = _selectedContact.Email
                        });
                    }
                }
            }
        }
コード例 #22
0
 private void QueryValues()
 {
     Android.Net.Uri          allLocations = LocationContentProvider.CONTENT_URI;
     Android.Database.ICursor c            = ManagedQuery(allLocations, null, null, null, "name DESC");
     if (c.MoveToFirst())
     {
         do
         {
             System.Diagnostics.Debug.WriteLine("Location:\n"
                                                + "ID: " + c.GetString(c.GetColumnIndex(LocationContentProvider._ID)) + "\n"
                                                + "Name: " + c.GetString(c.GetColumnIndex(LocationContentProvider.NAME)) + "\n"
                                                + "Latitude: " + c.GetString(c.GetColumnIndex(LocationContentProvider.LATITUTDE)) + "\n"
                                                + "Longitude: " + c.GetString(c.GetColumnIndex(LocationContentProvider.LONGITUDE)) + "\n"
                                                );
         }while (c.MoveToNext());
     }
 }
コード例 #23
0
        private string GetRealPathFromMediaStoreImageURI(Android.Net.Uri contentUri)
        {
            Context ctx = AndroidGlobals.MainActivity;

            try
            {
                if (string.IsNullOrEmpty(contentUri.LastPathSegment))
                {
                    return(null);
                }

                string[] idParts = contentUri.LastPathSegment.Split(new char[] { ':' });

                if (idParts.Length < 2)
                {
                    return(null);
                }

                string id = idParts[1];

                Android.Net.Uri uri = MediaStore.Images.Media.ExternalContentUri;

                string   selection = "_id=?";
                string[] selArgs   = new string[] { id };

                var      mediaStoreImagesMediaData = "_data";
                string[] projection = { mediaStoreImagesMediaData };

                Android.Database.ICursor cursor = this.ApplicationContext.ContentResolver.Query(uri, projection, selection, selArgs, null);

                if (null != cursor)
                {
                    cursor.MoveToFirst();

                    return(cursor.GetString(0));
                }
            }
            catch (Exception ex)
            {
                MobileGlobals.AddNewException(ex);
                MobileGlobals.WriteExceptionLog();
            }

            return(null);
        }
コード例 #24
0
 private void QueryValues()
 {
     Android.Net.Uri          allLocations = LocationContentProvider.CONTENT_URI;
     Android.Database.ICursor c            = ManagedQuery(allLocations, null, null, null, "name DESC");
     if (c.MoveToFirst())
     {
         do
         {
             // This will show in the output window of Visual Studio // MonoDevelop when you run it in debug mode
             System.Diagnostics.Debug.WriteLine("Location:\n"
                                                + "ID: " + c.GetString(c.GetColumnIndex(LocationContentProvider._ID)) + "\n"
                                                + "Name: " + c.GetString(c.GetColumnIndex(LocationContentProvider.NAME)) + "\n"
                                                + "Latitude: " + c.GetString(c.GetColumnIndex(LocationContentProvider.LATITUTDE)) + "\n"
                                                + "Longitude: " + c.GetString(c.GetColumnIndex(LocationContentProvider.LONGITUDE)) + "\n"
                                                );
         }while (c.MoveToNext());
     }
 }
コード例 #25
0
        public string[] GetContact()
        {
            var db    = helper.ReadableDatabase;
            var lines = new List <string>();

            Android.Database.ICursor cursor = db.Query("receiver", null, null, null, null, null, null);
            if (cursor.MoveToFirst())
            {
                do
                {
                    var receiveAddress = cursor.GetString(cursor.GetColumnIndex("receiveaddress"));
                    lines.Add(receiveAddress);
                } while (cursor.MoveToNext());
            }
            ;
            db.Dispose();
            return(lines.ToArray());
        }
コード例 #26
0
 public static string GetRealPathFromUri(Context context, Android.Net.Uri contentUri)
 {
     Android.Database.ICursor cursor = null;
     try
     {
         string[] proj = { MediaStore.Images.Media.InterfaceConsts.Data };
         cursor = context.ContentResolver.Query(contentUri, proj, null, null, null);
         int column_index = cursor.GetColumnIndexOrThrow(MediaStore.Images.Media.InterfaceConsts.Data);
         cursor.MoveToFirst();
         return(cursor.GetString(column_index));
     }
     finally
     {
         if (cursor != null && !cursor.IsClosed)
         {
             cursor.Close();
         }
     }
 }
コード例 #27
0
        public string GetAppLog()
        {
            var db     = helper.ReadableDatabase;
            var logstr = new StringBuilder();

            Android.Database.ICursor cursor = db.Query("applog", null, null, null, null, null, null);
            if (cursor.MoveToFirst())
            {
                do
                {
                    logstr.AppendLine(string.Format("{0}--{1}",
                                                    cursor.GetString(cursor.GetColumnIndex("content")),
                                                    cursor.GetString(cursor.GetColumnIndex("updatetime"))));
                } while (cursor.MoveToNext());
            }
            ;
            db.Dispose();
            return(logstr.ToString());
        }
コード例 #28
0
        public Dictionary <string, string> GetConfig()
        {
            var db  = helper.ReadableDatabase;
            var dic = new Dictionary <string, string>();

            Android.Database.ICursor cursor = db.Query("smsconfig", null, null, null, null, null, null);
            if (cursor.MoveToFirst())
            {
                dic.Add("messagetemplate", cursor.GetString(cursor.GetColumnIndex("messagetemplate")));
                dic.Add("smtpserver", cursor.GetString(cursor.GetColumnIndex("smtpserver")));
                dic.Add("smtpaccount", cursor.GetString(cursor.GetColumnIndex("smtpaccount")));
                dic.Add("smtppassword", cursor.GetString(cursor.GetColumnIndex("smtppassword")));
                dic.Add("controlphone", cursor.GetString(cursor.GetColumnIndex("controlphone")));
                dic.Add("smtpport", cursor.GetString(cursor.GetColumnIndex("smtpport")));
            }
            ;
            db.Dispose();
            return(dic);
        }
コード例 #29
0
        private void Test()
        {
            Android.Net.Uri uri        = ContactsContract.Contacts.ContentUri;
            string[]        projection =
            {
                ContactsContract.Contacts.InterfaceConsts.Id,
                ContactsContract.Contacts.InterfaceConsts.DisplayName,
            };
            Android.Database.ICursor cursor      = Application.Context.ContentResolver.Query(uri, projection, null, null, null);
            List <string>            contactList = new List <string>();

            if (cursor.MoveToFirst())
            {
                do
                {
                    contactList.Add(cursor.GetString(cursor.GetColumnIndex(projection[1])));
                } while (cursor.MoveToNext());
            }
        }
コード例 #30
0
        protected override void OnNewIntent(Intent intent)
        {
            if (intent.Action == Intent.ActionSend)
            {
                ClipData.Item item = intent.ClipData.GetItemAt(0);

                // Pega o nome do arquivo que está sendo compartilhado
                Android.Database.ICursor returnCursor = ContentResolver.Query(item.Uri, null, null, null, null);
                int index = returnCursor.GetColumnIndex(Android.Provider.OpenableColumns.DisplayName);
                returnCursor.MoveToFirst();
                string ext = Path.GetExtension(returnCursor.GetString(index));

                var filestream = ContentResolver.OpenInputStream(item.Uri);

                App.LoadFromSendTo(filestream, ext);
            }

            base.OnNewIntent(intent);
        }