What I’ve learned from my previous article is that the best way to gain new knowledge about a certain topic is to write about it. When I first wrote the article, I had no idea that you can create custom sampledata for your Android project. (If you don’t have a clue what sampledata is, please read tools:title=”LayoutPreview”) And then someone sent me this:

It sounded like a really cool feature, so I made the list of my favourite characters from Lord of the Rings, used it as sampledata , and got this glorious layout preview.

Later on, I wanted to include it in my other projects, but the only option that I had was to copy/paste the sampledata from one project to another, and that didn’t make any sense. Then I did what every (lazy) developer would do, asked a question on StackOverflow.

After 10 views and no answer in sight, I’ve decided to sacrifice a bit of my reputation and start a bounty. And it worked. I got my answer, which I will share with you.

To use sampledata between multiple projects you first have to host it and then have a Gradle script which will download it into your project’s sampledata folder. This is the code which does that: