0

I'm new to Android development and I'm basically developing my first app asides the HelloWorld examples and all. Now what I want to do is get data from a database (MySQL), I'm using PHP for server-side. The kind of data needed to be collected are blog entries where there are titles, post-images and excerpts. How do I get them in an array such that I'll be able to list them in a ListView. Actually, I have an idea running in my head which is - get all data and embed them in custom tags using php as in:

<item1>
    <post-title>Title of post goes here</post-title>
    <post-image>http://someimagelink.com</post-image>
    <post-excerpt>Some part of the post body</post-excerpt>
</item1>

And same goes for item2, item3, item3 etc which is representing the ListView rows respectively. Then I'll use a regex to search between each opening and closing tags. I don't know if this idea is lame, lol but I know definitely that its tedious. So I was thinking if there were a direct way handle such task as this or if someone could explain a more simpler way to do this. Thanks

Skeellz
  • 71
  • 1
  • 7

2 Answers2

0

You might use jsoup to parse the response. It's as simple as writing jQuery/CSS selectors.

Jonas Köritz
  • 2,606
  • 21
  • 33
-1

That requires a long answer. the short one is: you need to connect to your db using a mysql connector for java. there are plenty of resources and tutorial out there to learn how to use it (like this). Sorry but a real answer to this question will require a blog post. I just gave you the tools to start. good luck!

carlo.marinangeli
  • 2,958
  • 2
  • 17
  • 17