<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DevDiary</title>
	<atom:link href="http://devdiary.eu/feed/" rel="self" type="application/rss+xml" />
	<link>http://devdiary.eu</link>
	<description>The sophisticated art of (web) programming</description>
	<lastBuildDate>Thu, 08 Sep 2011 18:46:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Sending SMS</title>
		<link>http://devdiary.eu/sending-sms/</link>
		<comments>http://devdiary.eu/sending-sms/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 18:20:34 +0000</pubDate>
		<dc:creator>msx2</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[android.permission]]></category>
		<category><![CDATA[intent]]></category>
		<category><![CDATA[permission]]></category>
		<category><![CDATA[sms]]></category>
		<category><![CDATA[smsmanager]]></category>

		<guid isPermaLink="false">http://localhost/devdiary/?p=44</guid>
		<description><![CDATA[Android provides two ways of sending SMS using SDK. First of them is to use Intent library with proper configuration to use system&#8217;s messaging application. The second one is to use the SmsManager, what allows us to send SMS without any further question and confirmation. Let&#8217;s consider the latter one. First, we need the permission: [...]]]></description>
			<content:encoded><![CDATA[<p>Android provides two ways of sending SMS using SDK. First of them is to use <em class="code">Intent</em> library with proper configuration to use system&#8217;s messaging application. The second one is to use the <em class="code">SmsManager</em>, what allows us to send SMS without any further question and confirmation. Let&#8217;s consider the latter one.<span id="more-44"></span></p>
<p>First, we need the permission:</p>

<div class="wp_code"><div class="pre"><pre class="xml" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;uses-permission</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.permission.SEND_SMS&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Having proper permissions, we can use the following code:</p>

<div class="wp_code"><div class="pre"><pre class="java" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> sendSMS<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> phoneNumber, <span style="color: #003399;">String</span> recipientName, <span style="color: #003399;">String</span> message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		SmsManager sms <span style="color: #339933;">=</span> SmsManager.<span style="color: #006633;">getDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Sending</span>
		sms.<span style="color: #006633;">sendTextMessage</span><span style="color: #009900;">&#40;</span>phoneNumber, <span style="color: #000066; font-weight: bold;">null</span>, message, <span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Confirm window</span>
		Toast.<span style="color: #006633;">makeText</span><span style="color: #009900;">&#40;</span>getBaseContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
				<span style="color: #0000ff;">&quot;Your message to &quot;</span> <span style="color: #339933;">+</span> recipientName <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; has been sent! :)&quot;</span>,
				Toast.<span style="color: #006633;">LENGTH_LONG</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		Toast.<span style="color: #006633;">makeText</span><span style="color: #009900;">&#40;</span>getBaseContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
				<span style="color: #0000ff;">&quot;Your message could not be sent. Try again later.&quot;</span>,
				Toast.<span style="color: #006633;">LENGTH_LONG</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The code above uses <em class="code">SmsManager</em> class imported from <em class="code">android.telephony.SmsManager</em> and <strong>not</strong> from <em class="code">android.telephony.gsm.SmsManager</em> &#8211; this one is deprecated and should not be used.</p>
<p>Additionally, we can put the <em class="code">Intent</em> instances as parameters of <em class="code">sms.sendTextMessage()</em> to start the activity when the SMS is sent and/or when it gets delivered, according to manual:</p>

<div class="wp_code"><div class="pre"><pre class="java" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #000066; font-weight: bold;">void</span> android.<span style="color: #006633;">telephony</span>.<span style="color: #006633;">SmsManager</span>.<span style="color: #006633;">sendTextMessage</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> destinationAddress, <span style="color: #003399;">String</span> scAddress, <span style="color: #003399;">String</span> text, PendingIntent sentIntent, PendingIntent deliveryIntent<span style="color: #009900;">&#41;</span></pre></div></div>

<p><strong>Please note that sending SMS may incur additional fees.</strong></p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fsending-sms%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fsending-sms%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fsending-sms%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fsending-sms%2F&amp;count=none&amp;text=Sending%20SMS" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fsending-sms%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fsending-sms%2F&amp;count=none&amp;text=Sending%20SMS" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fsending-sms%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fsending-sms%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fdevdiary.eu%2Fsending-sms%2F&amp;linkname=Sending%20SMS" title="Facebook" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_email" href="http://www.addtoany.com/add_to/email?linkurl=http%3A%2F%2Fdevdiary.eu%2Fsending-sms%2F&amp;linkname=Sending%20SMS" title="Email" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/email.png" width="16" height="16" alt="Email"/></a><a class="a2a_button_blip" href="http://www.addtoany.com/add_to/blip?linkurl=http%3A%2F%2Fdevdiary.eu%2Fsending-sms%2F&amp;linkname=Sending%20SMS" title="Blip" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/blip.png" width="16" height="16" alt="Blip"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdevdiary.eu%2Fsending-sms%2F&amp;title=Sending%20SMS" id="wpa2a_2">Other</a></p>]]></content:encoded>
			<wfw:commentRss>http://devdiary.eu/sending-sms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backup all MySQL databases into separate compressed files</title>
		<link>http://devdiary.eu/backup-all-mysql-databases-into-separate-compressed-files/</link>
		<comments>http://devdiary.eu/backup-all-mysql-databases-into-separate-compressed-files/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 04:06:46 +0000</pubDate>
		<dc:creator>msx2</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bzip2]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://devdiary.eu/?p=167</guid>
		<description><![CDATA[The easiest way of making backup is to use mysqldump, but it may not be as easy as it seems. Although there is a flag &#8211;all-databases, it results in dumping everything into a single file. Let&#8217;s consider the following situation: you want to make automatic backup of each database on the server into the separate, [...]]]></description>
			<content:encoded><![CDATA[<p>The easiest way of making backup is to use <em class="code">mysqldump</em>, but it may not be as easy as it seems. Although there is a flag <em class="code">&#8211;all-databases</em>, it results in dumping everything into a single file.</p>
<p>Let&#8217;s consider the following situation: you want to make automatic backup of each database on the server into the separate, bzip2 compressed file named with the date; and you want to store backups only for 7 days. Sounds a bit challenging?<br />
<span id="more-167"></span><br />
Here comes the solution:</p>

<div class="wp_code"><div class="pre"><pre class="bash" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># @author       Konrad Jurkowski</span>
<span style="color: #666666; font-style: italic;"># @version      0.1</span>
<span style="color: #666666; font-style: italic;"># Shell script that dumps each of MySQL databases into a different file with in-fly bzip2 compression</span>
<span style="color: #666666; font-style: italic;"># Separate files are easier to restore</span>
<span style="color: #666666; font-style: italic;"># Also, script removes all backups of each database that are older than 7 days</span>
&nbsp;
<span style="color: #007800;">USER</span>=<span style="color: #ff0000;">&quot;user.name&quot;</span>
<span style="color: #007800;">PASSWORD</span>=<span style="color: #ff0000;">&quot;user.password&quot;</span>
<span style="color: #007800;">BACKUPDIR</span>=<span style="color: #ff0000;">&quot;/directory/to/store/backups&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Getting a list of current databases</span>
<span style="color: #007800;">databases</span>=<span style="color: #000000; font-weight: bold;">`</span>mysql <span style="color: #660033;">--user</span>=<span style="color: #007800;">$USER</span> <span style="color: #660033;">--password</span>=<span style="color: #007800;">$PASSWORD</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;SHOW DATABASES;&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;| &quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> Database<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Dumping all databases one by one</span>
<span style="color: #000000; font-weight: bold;">for</span> db <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$databases</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #666666; font-style: italic;"># Displaying the name of the database being dumped</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$db</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Finding and removing every backup of currently dumping database that is older than 7 days</span>
    <span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #007800;">$BACKUPDIR</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$db</span>*&quot;</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-mtime</span> +<span style="color: #000000;">7</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Dumping the content and in-fly compression</span>
    mysqldump <span style="color: #660033;">--single-transaction</span> <span style="color: #660033;">--force</span> <span style="color: #660033;">--opt</span> <span style="color: #660033;">--user</span>=<span style="color: #007800;">$USER</span> <span style="color: #660033;">--password</span>=<span style="color: #007800;">$PASSWORD</span> <span style="color: #660033;">--databases</span> <span style="color: #007800;">$db</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bzip2</span> <span style="color: #660033;">-c9</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUPDIR</span>/<span style="color: #007800;">$db</span>.<span style="color: #007800;">$(date +%Y-%m-%d.%H%M)</span>.sql.bz2&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>Don&#8217;t forget to make script&#8217;s file executable (<em class="code">chmod</em> +x) and to install <em class="code">bzip2</em> if necessary!</p>
<p>If you want to make periodical backups, simply put into the <em class="code">crontab</em>, i.e. for every day at 4 AM it would be:</p>

<div class="wp_code"><div class="pre"><pre class="vim" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000; font-weight:bold;">4</span> <span style="color: #000000;">*</span> <span style="color: #000000;">*</span> <span style="color: #000000;">*</span>    <span style="color: #668080;">sh</span> <span style="color: #000000;">/</span><span style="color: #668080;">directory</span><span style="color: #000000;">/</span>with<span style="color: #000000;">/</span>file<span style="color: #000000;">/</span><span style="color: #668080;">backup</span><span style="color: #000000;">.</span><span style="color: #668080;">sh</span> <span style="color: #000000;">&gt;</span> <span style="color: #000000;">/</span>dev<span style="color: #000000;">/</span>null <span style="color: #000000;">&amp;</span></pre></div></div>

<p>The backup task will be executed into the background without any visible output.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fbackup-all-mysql-databases-into-separate-compressed-files%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fbackup-all-mysql-databases-into-separate-compressed-files%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fbackup-all-mysql-databases-into-separate-compressed-files%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fbackup-all-mysql-databases-into-separate-compressed-files%2F&amp;count=none&amp;text=Backup%20all%20MySQL%20databases%20into%20separate%20compressed%20files" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fbackup-all-mysql-databases-into-separate-compressed-files%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fbackup-all-mysql-databases-into-separate-compressed-files%2F&amp;count=none&amp;text=Backup%20all%20MySQL%20databases%20into%20separate%20compressed%20files" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fbackup-all-mysql-databases-into-separate-compressed-files%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fbackup-all-mysql-databases-into-separate-compressed-files%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fdevdiary.eu%2Fbackup-all-mysql-databases-into-separate-compressed-files%2F&amp;linkname=Backup%20all%20MySQL%20databases%20into%20separate%20compressed%20files" title="Facebook" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_email" href="http://www.addtoany.com/add_to/email?linkurl=http%3A%2F%2Fdevdiary.eu%2Fbackup-all-mysql-databases-into-separate-compressed-files%2F&amp;linkname=Backup%20all%20MySQL%20databases%20into%20separate%20compressed%20files" title="Email" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/email.png" width="16" height="16" alt="Email"/></a><a class="a2a_button_blip" href="http://www.addtoany.com/add_to/blip?linkurl=http%3A%2F%2Fdevdiary.eu%2Fbackup-all-mysql-databases-into-separate-compressed-files%2F&amp;linkname=Backup%20all%20MySQL%20databases%20into%20separate%20compressed%20files" title="Blip" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/blip.png" width="16" height="16" alt="Blip"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdevdiary.eu%2Fbackup-all-mysql-databases-into-separate-compressed-files%2F&amp;title=Backup%20all%20MySQL%20databases%20into%20separate%20compressed%20files" id="wpa2a_4">Other</a></p>]]></content:encoded>
			<wfw:commentRss>http://devdiary.eu/backup-all-mysql-databases-into-separate-compressed-files/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Saving files to the SD Card</title>
		<link>http://devdiary.eu/saving-files-to-the-sd-card/</link>
		<comments>http://devdiary.eu/saving-files-to-the-sd-card/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 05:00:41 +0000</pubDate>
		<dc:creator>msx2</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[android.permission]]></category>
		<category><![CDATA[permission]]></category>
		<category><![CDATA[sd card]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://devdiary.eu/?p=151</guid>
		<description><![CDATA[At some point, an Android developer starts wondering where to store application&#8217;s additional content (i.e. images generated during the runtime) to preserve the efficiency and free space on the device. There are few answers to that riddle, but let&#8217;s consider the use of an SD Card. First and the most obvious problem can be finding [...]]]></description>
			<content:encoded><![CDATA[<p>At some point, an Android developer starts wondering where to store application&#8217;s additional content (i.e. images generated during the runtime) to preserve the efficiency and free space on the device. There are few answers to that riddle, but let&#8217;s consider the use of an SD Card.</p>
<p>First and the most obvious problem can be finding the card&#8217;s path. Most likely, it will be either <em class="code">/sdcard</em> or <em class="code">/mnt/sdcard</em>. It means that hard coding the path(s) is not such a good idea, isn&#8217;t it? Fortunately, you can get the card&#8217;s path by querying the system with:</p>

<div class="wp_code"><div class="pre"><pre class="java" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #003399;">Environment</span>.<span style="color: #006633;">getExternalStorageDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p><span id="more-151"></span></p>
<p>Knowing how to obtain the card&#8217;s path, we can proceed with coding &#8211; make additional directory tree for our application&#8217;s sake, put there some files and use them in the future. In the code below, let&#8217;s assume that</p>

<div class="wp_code"><div class="pre"><pre class="java" style="font-family:'Times New Roman',Garamond, Times;">Bitmap bm</pre></div></div>

<p>is not set to null and contains proper data.</p>

<div class="wp_code"><div class="pre"><pre class="java" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #666666; font-style: italic;">// Getting the SDCard's path (location)</span>
<span style="color: #003399;">String</span> path <span style="color: #339933;">=</span> <span style="color: #003399;">Environment</span>.<span style="color: #006633;">getExternalStorageDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Creating a separate directory for application's images</span>
<span style="color: #666666; font-style: italic;">// if it does not exist</span>
<span style="color: #003399;">File</span> directory <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>path <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;/our_directory&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>directory.<span style="color: #006633;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	directory.<span style="color: #006633;">mkdirs</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Creating a new JPG file</span>
<span style="color: #003399;">File</span> file <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>directory.<span style="color: #006633;">getAbsolutePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;filename.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Compressing the bitmap and saving it to the file above</span>
<span style="color: #003399;">OutputStream</span> fOut <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileOutputStream</span><span style="color: #009900;">&#40;</span>file<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
bm.<span style="color: #006633;">compress</span><span style="color: #009900;">&#40;</span>Bitmap.<span style="color: #006633;">CompressFormat</span>.<span style="color: #006633;">JPEG</span>, <span style="color: #cc66cc;">100</span>,
		fOut<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fOut.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fOut.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Before you run this code, <strong>make sure</strong> you have added in the <em class="code">AndroidManifest.xml</em> file the following permission:</p>

<div class="wp_code"><div class="pre"><pre class="xml" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;uses-permission</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Please note that &#8220;there is no SDCard in the device&#8221; situation is not considered in the example above. To make sure SDCard is present <strong>and writable</strong>, you may want to use:</p>

<div class="wp_code"><div class="pre"><pre class="java" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">boolean</span> isSdCardAvailable<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #003399;">Environment</span>.<span style="color: #006633;">getExternalStorageState</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Environment</span>.<span style="color: #006633;">MEDIA_MOUNTED</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>If the card is present and writable, this method will return <em class="code">true</em> and <em class="code">false</em> otherwise.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fsaving-files-to-the-sd-card%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fsaving-files-to-the-sd-card%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fsaving-files-to-the-sd-card%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fsaving-files-to-the-sd-card%2F&amp;count=none&amp;text=Saving%20files%20to%20the%20SD%20Card" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fsaving-files-to-the-sd-card%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fsaving-files-to-the-sd-card%2F&amp;count=none&amp;text=Saving%20files%20to%20the%20SD%20Card" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fsaving-files-to-the-sd-card%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fsaving-files-to-the-sd-card%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fdevdiary.eu%2Fsaving-files-to-the-sd-card%2F&amp;linkname=Saving%20files%20to%20the%20SD%20Card" title="Facebook" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_email" href="http://www.addtoany.com/add_to/email?linkurl=http%3A%2F%2Fdevdiary.eu%2Fsaving-files-to-the-sd-card%2F&amp;linkname=Saving%20files%20to%20the%20SD%20Card" title="Email" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/email.png" width="16" height="16" alt="Email"/></a><a class="a2a_button_blip" href="http://www.addtoany.com/add_to/blip?linkurl=http%3A%2F%2Fdevdiary.eu%2Fsaving-files-to-the-sd-card%2F&amp;linkname=Saving%20files%20to%20the%20SD%20Card" title="Blip" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/blip.png" width="16" height="16" alt="Blip"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdevdiary.eu%2Fsaving-files-to-the-sd-card%2F&amp;title=Saving%20files%20to%20the%20SD%20Card" id="wpa2a_6">Other</a></p>]]></content:encoded>
			<wfw:commentRss>http://devdiary.eu/saving-files-to-the-sd-card/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adding rows to a TableLayout during the runtime</title>
		<link>http://devdiary.eu/adding-rows-to-a-tablelayout-during-the-runtime/</link>
		<comments>http://devdiary.eu/adding-rows-to-a-tablelayout-during-the-runtime/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 06:00:13 +0000</pubDate>
		<dc:creator>msx2</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[row]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[tablelayout]]></category>
		<category><![CDATA[tablerow]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://localhost/devdiary/?p=113</guid>
		<description><![CDATA[Have you wondered how to create dynamic table in Android? It&#8217;s not really a hard thing to do, it just requires a XML template and some code in Java&#8230; shall we? This is the main.xml: &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;TableLayout xmlns:android=&#34;http://schemas.android.com/apk/res/android&#34; android:id=&#34;@+id/myTable&#34; android:layout_width=&#34;fill_parent&#34; android:layout_height=&#34;fill_parent&#34;&#62; &#60;TableRow android:layout_width=&#34;fill_parent&#34; android:layout_height=&#34;wrap_content&#34;&#62; &#60;Button android:text=&#34;Predefined&#34; /&#62; &#60;/TableRow&#62; &#60;/TableLayout&#62; And the piece of [...]]]></description>
			<content:encoded><![CDATA[<p>Have you wondered how to create dynamic table in Android? It&#8217;s not really a hard thing to do, it just requires a XML template and some code in Java&#8230; shall we?<span id="more-113"></span></p>
<p>This is the main.xml:</p>

<div class="wp_code"><div class="pre"><pre class="xml" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TableLayout</span> <span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/myTable&quot;</span> <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TableRow</span> <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Button</span> <span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;Predefined&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TableRow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TableLayout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>And the piece of code responsible for adding a row to the table presented in XML file above:</p>

<div class="wp_code"><div class="pre"><pre class="java" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">setContentView</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">main</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// First, get the TableLayout from main.xml</span>
TableLayout table <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>TableLayout<span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">myTable</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Then, create a row to be added</span>
TableRow row <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TableRow<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Set the parameters of width and height</span>
row.<span style="color: #006633;">setLayoutParams</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LayoutParams<span style="color: #009900;">&#40;</span>LayoutParams.<span style="color: #006633;">FILL_PARENT</span>,
		LayoutParams.<span style="color: #006633;">WRAP_CONTENT</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Create dynamic button</span>
<span style="color: #003399;">Button</span> button <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Button</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Give it a value</span>
button.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Dynamically added&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Set the parameters of width and height</span>
button.<span style="color: #006633;">setLayoutParams</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LayoutParams<span style="color: #009900;">&#40;</span>LayoutParams.<span style="color: #006633;">FILL_PARENT</span>,
		LayoutParams.<span style="color: #006633;">WRAP_CONTENT</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Add button to the previously created row</span>
row.<span style="color: #006633;">addView</span><span style="color: #009900;">&#40;</span>button<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// And finally, add a row to the table with parameters set</span>
table.<span style="color: #006633;">addView</span><span style="color: #009900;">&#40;</span>row, <span style="color: #000000; font-weight: bold;">new</span> TableLayout.<span style="color: #006633;">LayoutParams</span><span style="color: #009900;">&#40;</span>
		LayoutParams.<span style="color: #006633;">FILL_PARENT</span>, LayoutParams.<span style="color: #006633;">WRAP_CONTENT</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Before you run this code, <strong>make sure</strong> you have the correct import of <em class="code">LayoutParams</em>. In the case presented above it should be <em class="code">import android.widget.TableRow.LayoutParams</em>. If you import any other <em class="code">LayoutParams</em>, the code will not work properly and no row will be inserted.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fadding-rows-to-a-tablelayout-during-the-runtime%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fadding-rows-to-a-tablelayout-during-the-runtime%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fadding-rows-to-a-tablelayout-during-the-runtime%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fadding-rows-to-a-tablelayout-during-the-runtime%2F&amp;count=none&amp;text=Adding%20rows%20to%20a%20TableLayout%20during%20the%20runtime" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fadding-rows-to-a-tablelayout-during-the-runtime%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fadding-rows-to-a-tablelayout-during-the-runtime%2F&amp;count=none&amp;text=Adding%20rows%20to%20a%20TableLayout%20during%20the%20runtime" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fadding-rows-to-a-tablelayout-during-the-runtime%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fadding-rows-to-a-tablelayout-during-the-runtime%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fdevdiary.eu%2Fadding-rows-to-a-tablelayout-during-the-runtime%2F&amp;linkname=Adding%20rows%20to%20a%20TableLayout%20during%20the%20runtime" title="Facebook" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_email" href="http://www.addtoany.com/add_to/email?linkurl=http%3A%2F%2Fdevdiary.eu%2Fadding-rows-to-a-tablelayout-during-the-runtime%2F&amp;linkname=Adding%20rows%20to%20a%20TableLayout%20during%20the%20runtime" title="Email" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/email.png" width="16" height="16" alt="Email"/></a><a class="a2a_button_blip" href="http://www.addtoany.com/add_to/blip?linkurl=http%3A%2F%2Fdevdiary.eu%2Fadding-rows-to-a-tablelayout-during-the-runtime%2F&amp;linkname=Adding%20rows%20to%20a%20TableLayout%20during%20the%20runtime" title="Blip" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/blip.png" width="16" height="16" alt="Blip"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdevdiary.eu%2Fadding-rows-to-a-tablelayout-during-the-runtime%2F&amp;title=Adding%20rows%20to%20a%20TableLayout%20during%20the%20runtime" id="wpa2a_8">Other</a></p>]]></content:encoded>
			<wfw:commentRss>http://devdiary.eu/adding-rows-to-a-tablelayout-during-the-runtime/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Scrollable content on the screen</title>
		<link>http://devdiary.eu/scrollable-content-on-the-screen/</link>
		<comments>http://devdiary.eu/scrollable-content-on-the-screen/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 06:00:38 +0000</pubDate>
		<dc:creator>msx2</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[scroll]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://localhost/devdiary/?p=108</guid>
		<description><![CDATA[If you are not very familiar with all kinds of layouts and views used in Android, there is a great chance that (as me) you didn&#8217;t know about ScrollView and you have been wondering how to make content (i.e. of a table) scrollable. The basic layouts and structures do not support scrolls and once the [...]]]></description>
			<content:encoded><![CDATA[<p>If you are not very familiar with all kinds of layouts and views used in Android, there is a great chance that (as me) you didn&#8217;t know about <em class="code">ScrollView</em> and you have been wondering how to make content (i.e. of a table) scrollable. The basic layouts and structures do not support scrolls and once the table/list/whatever goes <em>below the screen</em>, its content just cuts off.<span id="more-108"></span></p>
<p>And here come two <em>special</em> views &#8211; <em class="code">ScrollView</em> (vertical) and <em class="code">HorizontalScrollView</em> (horizontal, as the name says). The XML code example:</p>

<div class="wp_code"><div class="pre"><pre class="xml" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ScrollView</span> <span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">android:scrollbars</span>=<span style="color: #ff0000;">&quot;vertical&quot;</span> <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TableLayout</span> <span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span> <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/myTable1&quot;</span> <span style="color: #000066;">android:scrollbars</span>=<span style="color: #ff0000;">&quot;vertical&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TableRow</span> <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextView</span> <span style="color: #000066;">android:padding</span>=<span style="color: #ff0000;">&quot;5dip&quot;</span> <span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;First line&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TableRow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TableRow</span> <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextView</span> <span style="color: #000066;">android:padding</span>=<span style="color: #ff0000;">&quot;5dip&quot;</span> <span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;Second line&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TableRow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TableRow</span> <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextView</span> <span style="color: #000066;">android:padding</span>=<span style="color: #ff0000;">&quot;5dip&quot;</span> <span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;Third line&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TableRow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TableLayout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ScrollView<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>With <em class="code">HorizontalScrollView</em> situation is alike. And if you want to have both in the same time, you will need a separate layer.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fscrollable-content-on-the-screen%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fscrollable-content-on-the-screen%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fscrollable-content-on-the-screen%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fscrollable-content-on-the-screen%2F&amp;count=none&amp;text=Scrollable%20content%20on%20the%20screen" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fscrollable-content-on-the-screen%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fscrollable-content-on-the-screen%2F&amp;count=none&amp;text=Scrollable%20content%20on%20the%20screen" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fscrollable-content-on-the-screen%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fscrollable-content-on-the-screen%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fdevdiary.eu%2Fscrollable-content-on-the-screen%2F&amp;linkname=Scrollable%20content%20on%20the%20screen" title="Facebook" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_email" href="http://www.addtoany.com/add_to/email?linkurl=http%3A%2F%2Fdevdiary.eu%2Fscrollable-content-on-the-screen%2F&amp;linkname=Scrollable%20content%20on%20the%20screen" title="Email" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/email.png" width="16" height="16" alt="Email"/></a><a class="a2a_button_blip" href="http://www.addtoany.com/add_to/blip?linkurl=http%3A%2F%2Fdevdiary.eu%2Fscrollable-content-on-the-screen%2F&amp;linkname=Scrollable%20content%20on%20the%20screen" title="Blip" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/blip.png" width="16" height="16" alt="Blip"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdevdiary.eu%2Fscrollable-content-on-the-screen%2F&amp;title=Scrollable%20content%20on%20the%20screen" id="wpa2a_10">Other</a></p>]]></content:encoded>
			<wfw:commentRss>http://devdiary.eu/scrollable-content-on-the-screen/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working with MySQL on Android</title>
		<link>http://devdiary.eu/working-with-mysql-on-android/</link>
		<comments>http://devdiary.eu/working-with-mysql-on-android/#comments</comments>
		<pubDate>Sun, 28 Aug 2011 23:30:52 +0000</pubDate>
		<dc:creator>msx2</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[android.permission]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[array list]]></category>
		<category><![CDATA[arraylist]]></category>
		<category><![CDATA[http client]]></category>
		<category><![CDATA[httpclient]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[permission]]></category>
		<category><![CDATA[remote]]></category>

		<guid isPermaLink="false">http://localhost/devdiary/?p=93</guid>
		<description><![CDATA[As you probably know, or at least should know now, all of the Android&#8217;s applications are desktop ones, what means there are some issues with remote files, connections etc. Although there is SQLite support in Android, it is possible only locally. What does it mean in real life? Well, nothing more that you should find [...]]]></description>
			<content:encoded><![CDATA[<p>As you probably know, or at least should know now, all of the Android&#8217;s applications are desktop ones, what means there are <em>some issues</em> with remote files, connections etc.</p>
<p>Although there is SQLite support in Android, it is possible only locally. What does it mean in real life? Well, nothing more that you should find a way to cheat the system. There is no perfect solution and there are plenty&#8230; well, a little more of them than the one I am going to describe here, but this one worked for me just fine and I didn&#8217;t try any other.</p>
<p>The cheat here is to put an intermediary PHP script on the remote server. Important thing here is the script should display data from the database as JSON-encoded string!<span id="more-93"></span> The script&#8217;s content could be as follows:</p>

<div class="wp_code"><div class="pre"><pre class="php" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Initialize variables here</span>
<span style="color: #339933;">...</span>
&nbsp;
<span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PDO<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysql:dbname='</span><span style="color: #339933;">.</span><span style="color: #000088;">$dbname</span><span style="color: #339933;">.</span><span style="color: #0000ff;">';host='</span><span style="color: #339933;">.</span><span style="color: #000088;">$dbhost</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbuser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbpass</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
PDO<span style="color: #339933;">::</span><span style="color: #004000;">MYSQL_ATTR_INIT_COMMAND</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'SET NAMES &quot;utf8&quot;'</span><span style="color: #339933;">,</span>
PDO<span style="color: #339933;">::</span><span style="color: #004000;">ATTR_DEFAULT_FETCH_MODE</span> <span style="color: #339933;">=&gt;</span> PDO<span style="color: #339933;">::</span><span style="color: #004000;">FETCH_ASSOC</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SELECT id, name, surname FROM people'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>If everything is displayed just like we planned, we can get data as a list of objects in Java. For that purpose I will use a small helper class I created just for the sole reason. Usage:</p>

<div class="wp_code"><div class="pre"><pre class="java" style="font-family:'Times New Roman',Garamond, Times;">ArrayList<span style="color: #339933;">&lt;</span>Person<span style="color: #339933;">&gt;</span> list <span style="color: #339933;">=</span> PersonSelector.<span style="color: #006633;">getResult</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://subdomain.domain/script.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The <em class="code">PersonSelector</em> class:</p>

<div class="wp_code"><div class="pre"><pre class="java" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.BufferedReader</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.InputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.InputStreamReader</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.HttpEntity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.HttpResponse</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.HttpClient</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.methods.HttpPost</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.impl.client.DefaultHttpClient</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.json.JSONArray</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.json.JSONException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.json.JSONObject</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.util.Log</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * 
 * A helper class for getting and parsing 'data from the database'
 * @author Konrad Jurkowski
 * @version 0.1
 * 
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">class</span> PersonSelector <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * 
	 * Getting a parsed data retrieved from the passed URL
	 * @param url URL address to retrieve JSON data from  
	 * @return null|A list of the Person objects
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> ArrayList<span style="color: #339933;">&lt;</span>Person<span style="color: #339933;">&gt;</span> getResult<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #003399;">String</span> jsonData <span style="color: #339933;">=</span> getJSONFromUrl<span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ArrayList<span style="color: #339933;">&lt;</span>Person<span style="color: #339933;">&gt;</span> list <span style="color: #339933;">=</span> parseJSON<span style="color: #009900;">&#40;</span>jsonData<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> list<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * 
	 * Retrieving JSON data from the passed URL
	 * @param url URL address to retrieve JSON data from
	 * @return JSON string or error information
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> getJSONFromUrl<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #003399;">InputStream</span> is <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">String</span> result <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Sending a request to the server</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			HttpClient httpclient <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			HttpPost httppost <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpPost<span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			HttpResponse response <span style="color: #339933;">=</span> httpclient.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>httppost<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			HttpEntity entity <span style="color: #339933;">=</span> response.<span style="color: #006633;">getEntity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// Retrieving response</span>
			is <span style="color: #339933;">=</span> entity.<span style="color: #006633;">getContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			result <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Error in http connection &quot;</span> <span style="color: #339933;">+</span> e.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			Log.<span style="color: #006633;">e</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;log_tag&quot;</span>, <span style="color: #0000ff;">&quot;Error in http connection &quot;</span> <span style="color: #339933;">+</span> e.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Converting server's response to string</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// Reading response</span>
			<span style="color: #003399;">BufferedReader</span> reader <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span>
					is, <span style="color: #0000ff;">&quot;utf-8&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			StringBuilder sb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StringBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">String</span> line <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// Reading response by lines and creating a string</span>
			<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>line <span style="color: #339933;">=</span> reader.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>line <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			is.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// Setting a built string as a result</span>
			result <span style="color: #339933;">=</span> sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			result <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Error converting result &quot;</span> <span style="color: #339933;">+</span> e.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			Log.<span style="color: #006633;">e</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;log_tag&quot;</span>, <span style="color: #0000ff;">&quot;Error converting result &quot;</span> <span style="color: #339933;">+</span> e.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 *
	 * Creating a list of data from JSON string
	 * @param data JSON data
	 * @return null|A list of Person objects
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> ArrayList<span style="color: #339933;">&lt;</span>Person<span style="color: #339933;">&gt;</span> parseJSON<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Data string is empty or contains an error</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>data <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> data.<span style="color: #006633;">startsWith</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
		ArrayList<span style="color: #339933;">&lt;</span>Person<span style="color: #339933;">&gt;</span> list <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Person<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// parse json data</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			JSONArray jArray <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONArray<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> jArray.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
				JSONObject json_data <span style="color: #339933;">=</span> jArray.<span style="color: #006633;">getJSONObject</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">// creating person</span>
				Person p <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				p.<span style="color: #006633;">setId</span><span style="color: #009900;">&#40;</span>json_data.<span style="color: #006633;">getInt</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				p.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span>json_data.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				p.<span style="color: #006633;">setSurname</span><span style="color: #009900;">&#40;</span>json_data.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;surname&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">// adding person to the list</span>
				list.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>JSONException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			Log.<span style="color: #006633;">e</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;log_tag&quot;</span>, <span style="color: #0000ff;">&quot;Error parsing data &quot;</span> <span style="color: #339933;">+</span> e.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			list <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> list<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>There is also used a local class named <em class="code">Person</em>, which is nothing more than:</p>

<div class="wp_code"><div class="pre"><pre class="java" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Person <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> id<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> name<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> surname<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setId<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">id</span> <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> id<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setName<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">name</span> <span style="color: #339933;">=</span> name<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> name<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setSurname<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> surname<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">surname</span> <span style="color: #339933;">=</span> surname<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getSurname<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> surname<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Before you run this code, <strong>make sure</strong> you have added in the <em class="code">AndroidManifest.xml</em> file the following permission:</p>

<div class="wp_code"><div class="pre"><pre class="xml" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;uses-permission</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.permission.INTERNET&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>I hope this solution will spare you some time. Comments, suggestions, pointing out mistakes and/or errors are appreciated. <img src='http://devdiary.eu/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fworking-with-mysql-on-android%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fworking-with-mysql-on-android%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fworking-with-mysql-on-android%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fworking-with-mysql-on-android%2F&amp;count=none&amp;text=Working%20with%20MySQL%20on%20Android" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fworking-with-mysql-on-android%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fworking-with-mysql-on-android%2F&amp;count=none&amp;text=Working%20with%20MySQL%20on%20Android" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fworking-with-mysql-on-android%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fworking-with-mysql-on-android%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fdevdiary.eu%2Fworking-with-mysql-on-android%2F&amp;linkname=Working%20with%20MySQL%20on%20Android" title="Facebook" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_email" href="http://www.addtoany.com/add_to/email?linkurl=http%3A%2F%2Fdevdiary.eu%2Fworking-with-mysql-on-android%2F&amp;linkname=Working%20with%20MySQL%20on%20Android" title="Email" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/email.png" width="16" height="16" alt="Email"/></a><a class="a2a_button_blip" href="http://www.addtoany.com/add_to/blip?linkurl=http%3A%2F%2Fdevdiary.eu%2Fworking-with-mysql-on-android%2F&amp;linkname=Working%20with%20MySQL%20on%20Android" title="Blip" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/blip.png" width="16" height="16" alt="Blip"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdevdiary.eu%2Fworking-with-mysql-on-android%2F&amp;title=Working%20with%20MySQL%20on%20Android" id="wpa2a_12">Other</a></p>]]></content:encoded>
			<wfw:commentRss>http://devdiary.eu/working-with-mysql-on-android/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DOMDocument and wrong output encoding</title>
		<link>http://devdiary.eu/domdocument-and-wrong-output-encoding/</link>
		<comments>http://devdiary.eu/domdocument-and-wrong-output-encoding/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 05:30:21 +0000</pubDate>
		<dc:creator>msx2</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[domdocument]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[unicode]]></category>
		<category><![CDATA[utf-8]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://localhost/devdiary/?p=72</guid>
		<description><![CDATA[Have you ever used DOMDocument class to analyze HTML structure of a random page (i.e. retrieved by cURL or something) loaded by loadHtml() method? Have you ever had difficulties with displaying national letters (diacritics) from analyzed content? It may occure when charset of the page was placed after the tag you tried to analyze (i.e. &#60;title&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever used <span class="code">DOMDocument</span> class to analyze HTML structure of a random page (i.e. retrieved by cURL or something) loaded by <em class="code">loadHtml()</em> method? Have you ever had difficulties with displaying national letters (diacritics) from analyzed content?</p>
<p>It may occure when charset of the page was placed after the tag you tried to analyze (i.e. <em class="code">&lt;title&gt;</em> before charset in the <em class="code">&lt;head&gt;</em> section).</p>
<p>Ironically<sup>1</sup>, if you process UTF-8 pages, DOM methods may return output with encoding different from input&#8217;s one. I admit I lost some time myself to find out what the problem was and trying to fix it. The easiest (and only that worked for me) way of fixing this issue is to use <em class="code">mb_convert_encoding()</em> function. The code goes as follows:</p>

<div class="wp_code"><div class="pre"><pre class="php" style="font-family:'Times New Roman',Garamond, Times;"><span style="color: #666666; font-style: italic;">// some code here</span>
<span style="color: #000088;">$dom</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DOMDocument<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$encodedPageSource</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_convert_encoding</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$basicPageSource</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'HTML-ENTITIES'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'UTF-8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadHTML</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$encodedPageSource</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// some code here</span></pre></div></div>

<p>Thanks to such convertion the arbitrary Unicode characters are inserted.</p>
<p><em class="small"><sup>1</sup> &#8211; the irony is DOMDocument only supports UTF-8</em></p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fdomdocument-and-wrong-output-encoding%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fdomdocument-and-wrong-output-encoding%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fdomdocument-and-wrong-output-encoding%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fdomdocument-and-wrong-output-encoding%2F&amp;count=none&amp;text=DOMDocument%20and%20wrong%20output%20encoding" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fdomdocument-and-wrong-output-encoding%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fdomdocument-and-wrong-output-encoding%2F&amp;count=none&amp;text=DOMDocument%20and%20wrong%20output%20encoding" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fdomdocument-and-wrong-output-encoding%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fdomdocument-and-wrong-output-encoding%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fdevdiary.eu%2Fdomdocument-and-wrong-output-encoding%2F&amp;linkname=DOMDocument%20and%20wrong%20output%20encoding" title="Facebook" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_email" href="http://www.addtoany.com/add_to/email?linkurl=http%3A%2F%2Fdevdiary.eu%2Fdomdocument-and-wrong-output-encoding%2F&amp;linkname=DOMDocument%20and%20wrong%20output%20encoding" title="Email" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/email.png" width="16" height="16" alt="Email"/></a><a class="a2a_button_blip" href="http://www.addtoany.com/add_to/blip?linkurl=http%3A%2F%2Fdevdiary.eu%2Fdomdocument-and-wrong-output-encoding%2F&amp;linkname=DOMDocument%20and%20wrong%20output%20encoding" title="Blip" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/blip.png" width="16" height="16" alt="Blip"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdevdiary.eu%2Fdomdocument-and-wrong-output-encoding%2F&amp;title=DOMDocument%20and%20wrong%20output%20encoding" id="wpa2a_14">Other</a></p>]]></content:encoded>
			<wfw:commentRss>http://devdiary.eu/domdocument-and-wrong-output-encoding/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>It has begun!</title>
		<link>http://devdiary.eu/it-has-begun/</link>
		<comments>http://devdiary.eu/it-has-begun/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 18:00:22 +0000</pubDate>
		<dc:creator>msx2</dc:creator>
				<category><![CDATA[Others]]></category>

		<guid isPermaLink="false">http://localhost/devdiary/?p=1</guid>
		<description><![CDATA[Hello there and welcome on my little blog. Hopefully it won&#8217;t be little for much longer and you will find it helpful in real life problems related to its main topic &#8211; (web) development and (web) programming. This is actually my very first blog of any kind so forgive me a lack of experience and [...]]]></description>
			<content:encoded><![CDATA[<p>Hello there and welcome on my little blog. Hopefully it won&#8217;t be little for much longer and you will find it helpful in real life problems related to its main topic &#8211; (web) development and (web) programming.</p>
<p>This is actually my very first blog of any kind so forgive me a lack of experience and grammar failures that may and will occur (however I&#8217;ll be grateful for pointing them all <img src='http://devdiary.eu/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ). But first things first &#8211; this blog has one purpose, and one purpose only: to store information. To store <span style="text-decoration: underline;">useful</span> information, tutorials and other kind of materials necessary for people who&#8217;d like to start (or have already started) their journey as (web) developers &#8211; mainly <strong>Facebook</strong> (Graph API with PHP/JavaScript) and <strong>Android</strong> (Android SDK) but other stuff may also be found in the future.</p>
<p>Enough with the foreplay. Enjoy being here!</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fit-has-begun%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevdiary.eu%2Fit-has-begun%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fit-has-begun%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fit-has-begun%2F&amp;count=none&amp;text=It%20has%20begun%21" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fdevdiary.eu%2Fit-has-begun%2F&amp;counturl=http%3A%2F%2Fdevdiary.eu%2Fit-has-begun%2F&amp;count=none&amp;text=It%20has%20begun%21" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fit-has-begun%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fdevdiary.eu%2Fit-has-begun%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fdevdiary.eu%2Fit-has-begun%2F&amp;linkname=It%20has%20begun%21" title="Facebook" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_email" href="http://www.addtoany.com/add_to/email?linkurl=http%3A%2F%2Fdevdiary.eu%2Fit-has-begun%2F&amp;linkname=It%20has%20begun%21" title="Email" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/email.png" width="16" height="16" alt="Email"/></a><a class="a2a_button_blip" href="http://www.addtoany.com/add_to/blip?linkurl=http%3A%2F%2Fdevdiary.eu%2Fit-has-begun%2F&amp;linkname=It%20has%20begun%21" title="Blip" rel="nofollow" target="_blank"><img src="http://devdiary.eu/wp-content/plugins/add-to-any/icons/blip.png" width="16" height="16" alt="Blip"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdevdiary.eu%2Fit-has-begun%2F&amp;title=It%20has%20begun%21" id="wpa2a_16">Other</a></p>]]></content:encoded>
			<wfw:commentRss>http://devdiary.eu/it-has-begun/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

