Tuesday, 18 February 2014

Gujarati language font support android example with source code

I had seen many developer struggling to support Guajarati language with android phone in their own application. Application like news hunt support Guajarati so that’s means its surely possible.

  • See very simple code to support Guajarati language inside android application. 

           TextView mtxt = (TextView) findViewById(R.id.action_settings); 

           Typeface face1 = Typeface.createFromAsset(getAssets(), 



           mtxt.setText("પૂર્વ વડાપ્રધાન રાજીવ ગાંધીની હત્યા કરનારા 3 આરોપીઓની ફાંસીની સજા સુપ્રિમ કોર્ટે ઉમ્રકેદમાં ફેરવી નાંખી છે.આમ રાજીવગાંધીના" + 

                     "3 હત્યારાઓને હવે ફાંસીની સજા નહી થાય.સુપ્રીમ કોર્ટમાં 3 જજોની બેન્ચે આજે આ ચુકાદો આ"); 

Gujrati Font in Android

Download source Code

Monday, 17 February 2014

Android FTP client tutorial with example of uploading, downloading and authentication with FTP server

FTP protocol is standard network protocol for transferring file. It works on peer to peer base network. In recent days I had written few articles about file transfer protocol and comparison among them to choose best. After research, research shows that FTP outperformed everything in android. So I decide to write about FTP client implementation. This tutorial will teach you
  • Android FTP client Authentication - How to connect with FTP server?
  • Android FTP client Download - How to download a file from FTP server?
  • Android FTP client Upload -How to upload a file to FTP server?

Basic requirement for this tutorial is one simple FTP server setup at your desktop. You can use file-Zilla or IIS server for this requirement.

  • Android FTP client authentication and listing file from FTP server

       * @param ip  
       * @param userName  
       * @param pass  
      public void connnectingwithFTP(String ip, String userName, String pass) {  
           boolean status = false;  
           try {  
                FTPClient mFtpClient = new FTPClient();  
                mFtpClient.setConnectTimeout(10 * 1000);  
                status = mFtpClient.login(userName, pass);  
                Log.e("isFTPConnected", String.valueOf(status));  
                if (FTPReply.isPositiveCompletion(mFtpClient.getReplyCode())) {  
                     FTPFile[] mFileArray = mFtpClient.listFiles();  
                     Log.e("Size", String.valueOf(mFileArray.length));  
           } catch (SocketException e) {  
           } catch (UnknownHostException e) {  
           } catch (IOException e) {  

  • Android FTP client download a file from FTP server – you can browse through directory saved on FTP server and can download desired file or directory. I just write code here for downloading a single file and writing it to sdcard/phone memory.

       * @param ftpClient FTPclient object  
       * @param remoteFilePath  FTP server file path  
       * @param downloadFile   local file path where you want to save after download  
       * @return status of downloaded file  
      public boolean downloadSingleFile(FTPClient ftpClient,  
                String remoteFilePath, File downloadFile) {  
           File parentDir = downloadFile.getParentFile();  
           if (!parentDir.exists())  
           OutputStream outputStream = null;  
           try {  
                outputStream = new BufferedOutputStream(new FileOutputStream(  
                return ftpClient.retrieveFile(remoteFilePath, outputStream);  
           } catch (Exception ex) {  
           } finally {  
                if (outputStream != null) {  
                     try {  
                     } catch (IOException e) {  
           return false;  

For browsing through directory see this Browsing Nested Directory

  • Android FTP client uploading a file to FTP server – You can upload a file to server with object of FTPClient at desired path which you need to define.

       * @param ftpClient FTPclient object  
       * @param downloadFile local file which need to be uploaded.  
      public void uploadFile(FTPClient ftpClient, File downloadFile,String serverfilePath) {  
           try {  
                FileInputStream srcFileStream = new FileInputStream(downloadFile);  
                boolean status = ftpClient.storeFile("remote ftp path",  
                Log.e("Status", String.valueOf(status));  
           } catch (Exception e) {  

Download Jar  


Note : Keep all methods inside background thread (i.e Asynchronous Task, Service)

 See Sambha file sharing client for android