Posts

Showing posts from September, 2018

My Map Application

Few days before I created one app, It's a map application. It's not a great application, but simple application. To load the data from the web, data has too be listed, when you select or click particular user data, load the map with marker. I tried with my knowledge, but don't expect too much. But it will be useful for beginners and peoples who are trying the map at first time. Get from the my GITHUB

Store and Get the data from Cache in Android.

It's Interesting, most of peoples thinks about the database, shared preferences and content providers for offline data storage. Some different came like data must be stored in cache, when app offline, retrieve data from the cache. Just try this, It might be useful for you. public String temp_filename = "user_data.txt"; public File tempFile; // To Store the file in Cache public void storeToCache(Context context, String data) {         if (data != null && !data.equals("")) {             FileWriter writer;             try {                 writer = new FileWriter(getCacheFile(context));                 writer.write(data);                 writer.close();                 Log.d(TAG, "stored to cache");             } catch (IOException e) {                 e.printStackTrace();             }         } } // To Check the file is exist or not public boolean isCacheExist(Context context) {         boolean isExist;         isExist =

Validate the URL

Have a great day friends. Today will look up validating the URL. How to do this? Most of times, your internet will be working, but sometimes URL to be busy or invalid. In this case, we follow this thing.  public boolean isServerReachable(Context context, String url) {         ConnectivityManager connMan = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);         NetworkInfo netInfo = connMan.getActiveNetworkInfo();         if (netInfo != null && netInfo.isConnected()) {             try {                 URL urlServer = new URL(url);                 if(url.startsWith("https")){                     HttpsURLConnection urlConn = (HttpsURLConnection) urlServer.openConnection();                     TLSSocketFactory socketFactory = new TLSSocketFactory();                     urlConn.setSSLSocketFactory(socketFactory);                     urlConn.setConnectTimeout(3000); //<- 3Seconds Timeout                     urlConn.connect();