[Java for Android App Development] Androguide.fr:
First, keep in mind you need a kernel with zRam support for those settings to work.

To set the zRam compression to the desired level (let's take 64mb as an example), you want to do something like this in a terminal :

su
busybox mkswap /dev/block/zram0
busybox swapon /dev/block/zram0
echo $((1024*1024*64)) > /sys/block/zram0/disksize [COLOR="Green"]// Replace 64 with the desired compression level[/COLOR]

So in java, this would translate to something like this :

A simple layout with an EditText for the user to input the desired zRam compression level & a Button to apply the value :

zram.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<EditText
android:id="@+id/userInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="48dp"
android:layout_marginRight="48dp"
android:layout_marginTop="32dp"
android:ellipsize="end"
android:hint="Enter zRam Compression Level"
android:inputType="number" />

<Button
android:id="@+id/apply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
android:text="Apply"
android:textColor="#33b5e5" />

</LinearLayout>

The corresponding java Class :

Zram.java

package com.rgocal.zram.settings;

import java.io.DataOutputStream;
import java.io.IOException;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Zram extends Activity implements OnClickListener {

private EditText input;
private Button apply;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.zram);

input = (EditText) findViewById(R.id.userInput);
apply = (Button) findViewById(R.id.apply);
apply.setOnClickListener(this);
}

@Override
public void onClick(View v) {

int value = Integer.parseInt(input.getText().toString());

// Arbitrary value, I don't know the maximum zRam compression (if
// there's one)
if (value > 200) {

Toast.makeText(
this,
"The value you entered is too high and may cause problems! Please reduce it",
Toast.LENGTH_SHORT).show();
} else {

try {
Process process = null;
process = Runtime.getRuntime().exec("su");

DataOutputStream os = new DataOutputStream(
process.getOutputStream());

os.writeBytes("busybox mkswap /dev/block/zram0" + "\n");
os.writeBytes("busybox swapon /dev/block/zram0" + "\n");
os.writeBytes("echo $((1024*1024*" + value
+ ")) > /sys/block/zram0/disksize" + "\n");

os.writeBytes("exit\n");
os.flush();
process.waitFor();

Log.v("zRam", "Compression level set to " + value);

} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}

Your AndroidManifest.xml :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rgocal.zram.settings.Zram"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="zRam Settings"
android:theme="@style/AppTheme" >
<activity
android:name="com.rgocal.zram.settings.Zram"
android:label="zRam Settings" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

The resulting apk : http://168.144.134.166/downloads/zRamSettings.apk

Screenshot :

I uploaded the full code on my github to make it easier for you to grab it : https://github.com/Androguide/zRamSettings

Hope this gets you going, good luck ;)