Using Android Device Monitor in Visual Studio to access locked folders

First you have to have your android emulator running

Then to open up the Android Device Monitor you click on the icon on the icon in visual studio

When it opens up it should look like

The Problem

When I click the icon next to data to look at the user data, I can’t see it because my device is not rooted. In order to get around this so I can verify file creation in my current development process. I force the ADB (android development bridge) to run as root.

So I open a command prompt via the toolbar and type adb root

Now when I view the folder in Android Device Monitor I can see the locked folder

Now there may be security concerns that I’m not aware of that make this a bad idea. The scenario for me that I need to do this is to verify that a file is created during my initial Android Applications activity is supposed to generate in the personal folder for the app.

C# Newtonsoft JSON Serialize and Deserialize of Objects

So after abit of headache. I figured out how to serialize nested objects and deserialize them. This is especially useful for doing Android Development with C#.

So for starters!

Here are the Objects/Models

public class Game

      public class Game
    {
        public Player currentPlayer;

        public Player player1;
        public Player player2;
        public Die die;
        public int currentRound;
        public bool canRoll;
        public bool gameOver;
        public Player winner;
}

public class Player

 [JsonObject(MemberSerialization.OptIn)]
    public class Player
    {
        [JsonProperty("Name")]
        public string Name { get; set; }
        [JsonProperty("Score")]
        public int Score { get; set; }
        [JsonProperty("FinalRollComplete")]
        public bool FinalRollComplete { get; set; }
    }

So the [JsonObject(MemberSerialization.OptIn)] is optional when everything is public. However if I had a protected class I would need it and the JsonProperty in order to store it in my json string.

 public class Die
    {
        [JsonProperty("currentValue")]
        public int currentValue;
}

Ok so now you know the setup, lets talk about the actual serialize and deserialize.

Serialize

string json = JsonConvert.SerializeObject(this.Game, Formatting.Indented);

Deserialize

 Game = JsonConvert.DeserializeObject<Game>(json);

So this also requires you install the NuGet package for Newtonsoft.Json and add the

using Newtonsoft.Json;

at the top