How to pass CustomObject/ArrayList from one activity to another? Using Parcelable

We’d like to pass an Object from one Activity to another in Java Android, there are two ways to do this operation, the first one is to use a Serializable Object while the second one is to use a Parcelable Object.

It is strongly recommended due to performance issues to use the first solution.

Imagine you have a Song Custom Object, you need implements Parcelable in your Song class:

import android.os.Parcel;
import android.os.Parcelable;

public class Song implements Parcelable {
    private String title;
    private String author;
    private String album;
    private String genre;
    private String location;

    public Song (String title, String author, String album, String genre, String location) {
        this.title = title;;

    public Song(Parcel in) { //Constructor when loading from Parcel
        title = in.readString();
        author = in.readString();
        album = in.readString();
        genre = in.readString();
        location = in.readString();

//Getters and Setters

    public String getAlbum() {
        return album;

    public void setAlbum(String album) {
        this.album = album;

    public String getTitle() {
        return title;

    public void setTitle(String title) {
        this.title = title;

    public String getAuthor() {
        return author;

    public void setAuthor(String author) { = author;

    public String getGenre() {
        return genre;

    public void setGenre(String genre) {
        this.genre = genre;

    public String getLocation() {
        return location;

    public void setLocation(String location) {
        this.location = location;

//Required method, but not used
    public int describeContents() {
        return 0;

    public void writeToParcel(Parcel dest, int flags) {

//When Parcel this Object write every variable to Parcel dest

//Parcelable Creator, every Parcelable Object should implement this method.

    public static final Parcelable.Creator<Song> CREATOR = new Parcelable.Creator<Song>() {
        public Song createFromParcel(Parcel in) {
            return new Song(in);

        public Song[] newArray(int size) {
            return new Song[size];

Then in the first Activity:

ArrayList<Song> passedList = new ArrayList <Song>();
Intent intent = new Intent(context, SecondActivity.class);
String pkg = getPackageName();
intent.putExtra(pkg+”values”, passedList);

In the second Activity:

ArrayList<Song> passedValues = getIntent().getParcelableArrayListExtra(pkg+”values”);

YouTube Downloader Android

YouTube Downloader: My New App! 😉

 Download your videos from YouTube and convert them to MP3 from your Android Device!

Convert your videos from YouTube to MP3s directly from your smartphone. Just open the official YouTube App, choose your video and tap on the share icon (top-right corner) and select YouTube Downloader, then Download your song…Enjoy!

– Amedeo

Folder Encrypter [FREE/PRO]

Folder Encrypter allows you to password-protect all your folders and to make them invisible in Android Gallery.
It hashes directory names and hide them from your File Manager.
Easy, secure and fast! 😉 Try it out.

Simple and clean interface!

• Protect your folders
• Hide Media Files from Gallery
• Hash directory name
• Clean Interface
• Simply hold a folder to unlock
• Priority Updates

Rate us!

Free Version:

PRO Version also available on Play Store 😉


Save Array List in shared preferences Android

Get the Arraylist:

String serialized = sharedPrefs.getString(“NAME”, “”);
//Changing this one to linkedlist should solve the java.lang.UnsupportedOperationException problem
myList =  new LinkedList(Arrays.asList(TextUtils.split(serialized,”,”)));

Save the Arraylist:

SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putString(“locked”, TextUtils.join(“,”, myList));

Android KitKat

Yep, our upcoming release will be named Android KitKat! 

KitKat has been a favorite candy on the team for some time, so for the K release, we asked if they’d be willing to lend their iconic candy bar to its name. Be on the lookout for limited edition Android KitKat bars coming soon to a candy aisle near you. For a lucky few, your KitKat bar might contain a winning ticket for a new Nexus 7 tablet or Google Play credits. Check it out


How to store a List in SharedPreferences using Gson

First of all you have to download Gson library from here:

And then install it in your IDE..For Android Studio you can follow this article..

Then: (from stackoverflow)

I found the easiest solution to store and retrieve a list of items from SharedPreferences is to simply serialize / deserilaize the array into / from JSON and store it into a string setting.

Gson comes really handy doing it.


SharedPreferences prefs = context.getSharedPreferences(“settings”, Context.MODE_PRIVATE);
String value = prefs.getString(“list”, null);
GsonBuilder gsonb = new GsonBuilder();
Gson gson = gsonb.create();
MyObject[] list = gson.fromJson(value, MyObject[].class);


String value = gson.toJson(list);
SharedPreferences prefs = context.getSharedPreferences(“settings”, Context.MODE_PRIVATE);
Editor e = prefs.edit();
e.putString(“list”, value);

How to import Jar in Android Studio

Answer from worked for me 😉

Steps to follow in order to import a JAR sucesfully to your project using Android Studio 0.1.1:

  • Download the library.jar file and copy it to your /libs/ folder inside your application project.
  • Open the build.gradle file and edit your dependencies to include the new .jar file:

compile files('libs/android-support-v4.jar', 'libs/GoogleAdMobAdsSdk-6.4.1.jar')

  • File -> Close Project
  • Open a command prompt on your project’s root location, i.e'C:UsersUsernameAndroidStudioProjectsMyApplicationProject'
  • On the command prompt, type gradlew clean, wait till it’s done.
  • Reopen your application project in Android Studio.
  • Test run your application and it should work succesfully.