This happened to me a while ago when I was traveling in Melbourne, Australia on tourism.
After I went through baggage claim at the airport, I was passing through the customs check, and was motioned to the side by one of the officers. They told me to empty all my bags, checked all my belongings thoroughly, and even emptied all the binders and folders I had in my hand bag to read all the papers I had in them (they even questioned me about a piece of paper that showed my body fat percentage, which I had obtained from a gym).
And of course, they asked me to enter my passcode in my phone. The customs officer read through a few of my emails, my text messages, and some messages I had sent through other apps like WhatsApp. I knew this wasn’t appropriate, but I was too tired to fight it at this point.
After that, they grilled me with more questions about the details of my messages without any suspicion / evidence of wrong doing. Finally (and luckily), they let me go.