fatal error: 'openssl/ssl.h' file not found on Mac

Correcting the problem - 

First make sure Command Line tools are already installed. 

xcode-select --install

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

using Brew to update openssl - 
sudo brew update
sudo brew install openssl
sudo brew link --force openssl

Adding curl library in C project in Xcode

1. Click over the project name in Xcode.
2. Go to "Build Phases" and expand "Link Binary with Libraries".
3. Click "+" sign and "Add Other". 
4. Click "Shift" + "Command" + "G". This will launch a folder select dialogue.
5. Go to "/usr/lib" and then select "libcurl.dylib".

Notes: SQL #Android

The schema is reflected in the SQL statements that you use to create your database. You may find it helpful to create a companion class, known as a contract class, which explicitly specifies the layout of your schema in a systematic and self-documenting way.
A contract class is a container for constants that define names for URIs, tables, and columns. The contract class allows you to use the same constants across all the other classes in the same package. This lets you change a column name in one place and have it propagate throughout your code.

A good way to organize a contract class is to put definitions that are global to your whole database in the root level of the class. Then create an inner class for each table that enumerates its columns.

Android stores your database in private disk space that's associated application. Your data is secure, because by default this area is not accessible to other applications.

A useful set of APIs is available in the SQLiteOpenHelper class. When you use this class to obtain references to your database, the system performs the potentially long-running operations of creating and updating the database only when needed and not during app startup. All you need to do is callgetWritableDatabase() or getReadableDatabase().
Note: Because they can be long-running, be sure that you call getWritableDatabase() or getReadableDatabase() in a background thread, such as with AsyncTask or IntentService.

The result isn't handled the same as a regular SQL statement, it is immune to SQL injection.

Notes: Saving files in #Android

All Android devices have two file storage areas: "internal" and "external" storage.  Some devices divide the permanent storage space into "internal" and "external" partitions, so even without a removable storage medium, there are always two storage spaces.

Internal storage is best when you want to be sure that neither the user nor other apps can access your files.External storage is the best place for files that don't require access restrictions and for files that you want to share with other apps or allow the user to access with a computer.

       Internal Storage:
When saving a file to internal storage, 
Returns a File representing an internal directory for your app.
Returns a File representing an internal directory for your app's temporary cache files. Be sure to delete each file once it is no longer needed and implement a reasonable size limit for the amount of memory you use at any given time, such as 1MB. If the system begins running low on storage, it may delete your cache files without warning.

You can call openFileOutput() to get a FileOutputStream that writes to a file in your internal directory or  if you need to cache some files, you should instead use createTempFile()

External Storage:

 You can query the external storage state by callinggetExternalStorageState(). If the returned state is equal to MEDIA_MOUNTED, then you can read and write your files.

Although the external storage is modifiable by the user and other apps, there are two categories of files you might save here:
Public files
Files that should be freely available to other apps and to the user. When the user uninstalls your app, these files should remain available to the user.
For example, photos captured by your app or other downloaded files.
Private files
Files that rightfully belong to your app and should be deleted when the user uninstalls your app. Although these files are technically accessible by the user and other apps because they are on the external storage, they are files that realistically don't provide value to the user outside your app. When the user uninstalls your app, the system deletes all files in your app's external private directory.

getFreeSpace() or getTotalSpace()- These methods provide the current available space and the total space in the storage volume, respectively. 

to delete a file is to have the opened file reference call delete()on itself.
If the file is saved on internal storage, you can also ask the Context to locate and delete a file by calling deleteFile():
Note: When the user uninstalls your app, the Android system deletes the following:
  • All files you saved on internal storage
  • All files you saved on external storage using getExternalFilesDir().
However, you should manually delete all cached files created with getCacheDir() on a regular basis and also regularly delete other files you no longer need.

Notes: Saving Data using Shared Preference

SharedPreferences object points to a file containing key-value pairs and provides simple methods to read and write them. Each SharedPreferences file is managed by the framework and can be private or shared.( for a relatively small collection of key-values)

You can create a new shared preference file or access an existing one by calling one of two methods:
  • getSharedPreferences() — Use this if you need multiple shared preference files identified by name, which you specify with the first parameter. You can call this from any Context in your app.
  • getPreferences() — Use this from an Activity if you need to use only one shared preference file for the activity. Because this retrieves a default shared preference file that belongs to the activity, you don't need to supply a name.
 If you create a shared preferences file with MODE_WORLD_READABLE or MODE_WORLD_WRITEABLE, then any other apps that know the file identifier can access your data.
To write to a shared preferences file, create a SharedPreferences.Editor by calling edit() on your SharedPreferences.
Pass the keys and values you want to write with methods such as putInt() and putString(). Then call commit() to save the changes.

Notes: Fragments in #Android

One difference when creating a Fragment is that you must use the onCreateView() callback to define the layout.

While fragments are reusable, modular UI components, each instance of a Fragment class must be associated with a parent FragmentActivityWhen you add a fragment to an activity layout by defining the fragment in the layout XML file, you cannot remove the fragment at runtime. If you plan to swap your fragments in and out during user interaction, you must add the fragment to the activity when the activity first starts

To perform a transaction such as add or remove a fragment, you must use the FragmentManager to create a FragmentTransaction, which provides APIs to add, remove, replace, and perform other fragment transactions.Inside your activity, call getSupportFragmentManager() to get a FragmentManager using the Support Library APIs. Then call beginTransaction() to create a FragmentTransaction and call add() to add a fragment.
You can perform multiple fragment transaction for the activity using the same FragmentTransaction. When you're ready to make the changes, you must call commit().

The procedure to replace a fragment is similar to adding one, but requires the replace() method instead of add().
Keep in mind that when you perform fragment transactions, such as replace or remove one, it's often appropriate to allow the user to navigate backward and "undo" the change. To allow the user to navigate backward through the fragment transactions, you must call addToBackStack() before you commit the FragmentTransaction.
Note: When you remove or replace a fragment and add the transaction to the back stack, the fragment that is removed is stopped (not destroyed). If the user navigates back to restore the fragment, it restarts. If you do not add the transaction to the back stack, then the fragment is destroyed when removed or replaced.
In order to reuse the Fragment UI components, you should build each as a completely self-contained, modular component that defines its own layout and behavior. Once you have defined these reusable Fragments, you can associate them with an Activity and connect them with the application logic to realize the overall composite UI.
Two Fragments should never communicate directly.
To allow a Fragment to communicate up to its Activity, you can define an interface in the Fragment class and implement it within the Activity. The Fragment captures the interface implementation during its onAttach() lifecycle method and can then call the Interface methods in order to communicate with the Activity.

The host activity can deliver messages to a fragment by capturing the Fragment instance with findFragmentById(), then directly call the fragment's public methods.

Setting System properties using ADB and accessing in #android code

ADB command to set system properties-

adb shell setprop test.android.Sysprop Sandeep 

Android code:

 try {

            Class clazz = Class.forName("android.os.SystemProperties");

            //Parameters Types
            Class[] paramTypes = new Class[1];
            paramTypes[0] = String.class;
            Method get = clazz.getMethod("get", paramTypes);

            Object[] params = new Object[1];
            params[0] = "test.android.Sysprop";
            String ret = (String) get.invoke(clazz, params);
        }catch(Exception e){

Remove .idea or some not needed files from remote

git rm -r --cached .idea
git rm -r --cached
git commit -m "Removing not necessary files"
git push origin  

To create an empty branch from master - local and remote

git checkout --orphan  EmptyBranch
git rm -rf .
git commit --allow-empty -m "initial commit"
git push -u origin EmptyBranch

Clash of Gradle classes for different versionsin #Android Studio - inactive functions

If your gradle path in Project Properties is pointing to one version of gradle like gradle 2.4

And the gradle wrapper file, gradle-wrapper.properties
in gradle/wrapper folder


there will be clash.

Result- You will not be able to see active gradle function links in build.gradle.

buildscript {
    repositories {
    dependencies {

        classpath 'com.android.tools.build:gradle:1.3.0'
        classpath 'org.robolectric:robolectric-gradle-plugin:0.14.+'
        classpath 'com.jakewharton.hugo:hugo-plugin:1.1.0'

If you Press Command+ Mouse Over on "buildscript" in build.gradle, you will not see an active link.