Q:

How to prevent double post of data from android to php file

I have this android app that posts (http post) some data strings to my php file that inserts the data to a mysql table. The problem is, the android app is posting data for about 30 seconds and when the internet connection were accidentally down or interrupted during the posting of data, the user is about to repost the data and so it makes double record on mysql database.
The datasource of my android app is a text file on the device sdcard. after successful posting of data (without interruption), that text file is supposedly deleted.

A:

As @subspider pointed out. Once the app posted a specific line, it must be deleted so that when internet connection was interrupted, and the user repost data, there will be no double post.
                    //check internet connection
                    if( isNetworkAvailable() == true ){
                        //post the data
                        postData( "sessions", sessionnumber, sessionFirstname, sessionIdNumber, sessionLastname, action, username, timestamp);
                        //clear the line/leave the line blank
                        whole_text = whole_text + "\n";
                    }else{
                        //0 means some failed
                        //if internet connection not detected
                        //leave that line as is
                        upload_log_status = 0;
                        whole_text = whole_text + line + "\n";
                    }

