Compare names of every resource with the content of a variable of sqlite database

前端 未结 2 582
谎友^
谎友^ 2020-12-17 01:42

I hope you can help me, I already researched my case but didn\'t found a good answer. I want to compare the content of a variable with the names of all existing resources (i

2条回答
  •  心在旅途
    2020-12-17 02:29

    Sorry, I know you were looking for a Java solution, but I did not find any solution for the C# and Xamarin issue in StackOverflow, so I will leave my solution for Android here if you don't mind.

    I found a well written class ReflectionUtils in GitHub, just used it and made this method to call.

        private List GetAllStrings()
        {
            IEnumerable fields = ReflectionUtils.GetAllFields(typeof(Resource.String));
            List list = new List();
            using (var enumerator = fields.GetEnumerator())
            {
                try
                {
                    while (enumerator.MoveNext())
                    {
                        list.Add(enumerator.Current.Name);
                    }
                } catch (Exception e)
                {
                    // Handle exception.
                }
            }
            return list;
        }
    

提交回复
热议问题