How to change your Device Id in Android

I will show you how to change your device id in an avd or in a real Android phone.

If you want to test this on an Android Virtual Device you just have to  follow the steps below. If you want to change your phone’s id then you must have your phone rooted.

Why you might want to change your id:

  1. Beacause you will install a new rom on your phone and you want to have the same id.
  2. Because it sounds cool.

First let’s write a simple Android application that reads our device id.

Activity code:

package com.vostdev.deviceid;

import android.app.Activity;
import android.provider.Settings.Secure;
import android.widget.TextView;
import android.os.Bundle;

public class DeviceId extends Activity {
    private String uuid = new String();
    private TextView txt;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txt = (TextView) findViewById(R.id.txt);
uuid = Secure.getString(this.getContentResolver(),Secure.ANDROID_ID);
txt.setText(uuid);
}}

Layout code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
    android:id="@+id/txt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>

Now run the application above and you will see your current id.
Next open a terminal and type:

adb shell
su
sqlite3 data/data/com.android.providers.settings/databases/settings.db
update secure set value=0000 where name=’android_id’;

Here I have changed the id to 0000 but you can changed it to anything you want.
Now run again the application above to see your new id.

NOTICE: If you see the same id, the one before the change, just stop the application and run it again because it holds the previous value.

That’s all!

2 Comments

  1. josh says:

    how and where do i import the activity code and the layout code? please help me out. thanks.

  2. For anything you want to do with your android device you should have installed the Android SDK. If you only need to change your device id you should open a terminal/command prompt and enter this:

    adb shell
    su
    sqlite3 data/data/com.android.providers.settings/databases/settings.db
    update secure set value=0000 where name=’android_id’;

    The Activity and the Layout code is the code of an Android application that reads your device id. If you don’t understand this then probably you are not an Android developer but you don’t need to understand or use any of this code..Use the lines I wrote above.;)

Leave a Comment