Skip to content

Instantly share code, notes, and snippets.


Grigore Cristian-Andrei grrigore

View GitHub Profile
granoeste /
Last active Nov 16, 2021
[Android] How to get the each directory path.

System directories

Method Result
Environment.getDataDirectory() /data
Environment.getDownloadCacheDirectory() /cache
Environment.getRootDirectory() /system

External storage directories

rxaviers / gist:7360908
Last active Dec 8, 2021
Complete list of github markdown emoji markup
View gist:7360908


:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
View Android Color Control Cheat Sheet
Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21.
To use the support version of these attributes, remove the android namespace.
For instance, "android:colorControlNormal" becomes "colorControlNormal".
These attributes will be propagated to their corresponding attributes within the android namespace
for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix.
All Clickable Views:
ryanamaral /
Created May 25, 2015
RecyclerView.ItemDecoration implementation for equal padding between the list items except first and last items.
* ItemDecoration implementation for equal padding between the list items except first and last items.
* @author Ryan Amaral
* @version 1.0
public class PaddingItemDecoration extends RecyclerView.ItemDecoration {
private int mPaddingPx;
private int mPaddingEdgesPx;
yqritc / gist:ccca77dc42f2364777e1
Last active Nov 30, 2021
Equal column spacing for Android RecyclerView GridLayoutManager by using custom ItemDecoration
View gist:ccca77dc42f2364777e1


public class ItemOffsetDecoration extends RecyclerView.ItemDecoration {

    private int mItemOffset;

    public ItemOffsetDecoration(int itemOffset) {
        mItemOffset = itemOffset;
cesarferreira /
Last active May 29, 2021
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
mcelotti / android_forward_result
Last active Nov 2, 2021
View android_forward_result
Nav flow is: A => B => C => A with results from C
If you're using fragments please note that "onActivityResult" will be called according to where "startActivityForResult" is called (method "startActivityForResult" is available in both, activity and fragment)
startActivityForResult(intentB, 22);
lopspower /
Last active Dec 8, 2021
Hexadecimal color code for transparency

Hexadecimal color code for transparency


How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

iChintanSoni /
Last active Dec 5, 2018
Utility class for working with SharedPreferences
import android.content.Context;
import android.content.SharedPreferences;
public class SharedPreferenceUtils {
private static SharedPreferenceUtils mSharedPreferenceUtils;
protected Context mContext;
private SharedPreferences mSharedPreferences;
private SharedPreferences.Editor mSharedPreferencesEditor;
private SharedPreferenceUtils(Context context) {
Antarix /
Created Nov 21, 2016
Firebase Android Sample for managing notification
import android.content.Context;
import android.content.Intent;
import android.util.Log;
* This is called whenever app receives notification
* in background/foreground state so you can
* apply logic for background task, but still Firebase notification
* will be shown in notification tray