Skip navigation

Sending SMS

Android provides two ways of sending SMS using SDK. First of them is to use Intent library with proper configuration to use system’s messaging application. The second one is to use the SmsManager, what allows us to send SMS without any further question and confirmation. Let’s consider the latter one. Read More »

Backup all MySQL databases into separate compressed files

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 –all-databases, it results in dumping everything into a single file.

Let’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?
Read More »

Saving files to the SD Card

At some point, an Android developer starts wondering where to store application’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’s consider the use of an SD Card.

First and the most obvious problem can be finding the card’s path. Most likely, it will be either /sdcard or /mnt/sdcard. It means that hard coding the path(s) is not such a good idea, isn’t it? Fortunately, you can get the card’s path by querying the system with:

Environment.getExternalStorageDirectory()

Read More »

Adding rows to a TableLayout during the runtime

Have you wondered how to create dynamic table in Android? It’s not really a hard thing to do, it just requires a XML template and some code in Java… shall we? Read More »

Scrollable content on the screen

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’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 table/list/whatever goes below the screen, its content just cuts off. Read More »

Working with MySQL on Android

As you probably know, or at least should know now, all of the Android’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 a way to cheat the system. There is no perfect solution and there are plenty… 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’t try any other.

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! Read More »

DOMDocument and wrong output encoding

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. <title> before charset in the <head> section).

Ironically1, if you process UTF-8 pages, DOM methods may return output with encoding different from input’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 mb_convert_encoding() function. The code goes as follows:

// some code here
$dom = new DOMDocument();
$encodedPageSource = mb_convert_encoding($basicPageSource, 'HTML-ENTITIES', 'UTF-8');
$dom->loadHTML($encodedPageSource);
// some code here

Thanks to such convertion the arbitrary Unicode characters are inserted.

1 – the irony is DOMDocument only supports UTF-8

It has begun!

Hello there and welcome on my little blog. Hopefully it won’t be little for much longer and you will find it helpful in real life problems related to its main topic – (web) development and (web) programming.

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’ll be grateful for pointing them all ;) ). But first things first – this blog has one purpose, and one purpose only: to store information. To store useful information, tutorials and other kind of materials necessary for people who’d like to start (or have already started) their journey as (web) developers – mainly Facebook (Graph API with PHP/JavaScript) and Android (Android SDK) but other stuff may also be found in the future.

Enough with the foreplay. Enjoy being here!