Tag Archives: System

JSON IN ANDROID.

By | April 26, 2012

Complex JSON String parsing in ANDROID http://www.coderzheaven.com/2011/06/10/complex-json-string-parsing-in-android/ Parsing JSON Object in ANDROID. http://www.coderzheaven.com/2011/06/09/parsing-json-objects-in-android/

How to explicitly free memory in android OR Release unwanted memory in Android?

By | April 24, 2012

If you are writing memory consuming applications there is a bigger chance that your application may be running out of memory after sometime. So there are some methods in android that invokes the garbage collector explicitly. See the following function which invokes the garbage collector to free a lot of memory. [java] public void freeMemory(){ System.runFinalization(); Runtime.getRuntime().gc(); System.gc();… Read More »

Java check memory Allocation

By | April 7, 2012

[java] class test { public static void main(String args[]) { Runtime r = Runtime.getRuntime(); long mem1, mem2; Integer someints[] = new Integer[1000]; System.out.println("Total memory is: " +r.totalMemory()); mem1 = r.freeMemory(); System.out.println("Initial free memory: " + mem1); r.gc(); mem1 = r.freeMemory(); System.out.println("Free memory after garbage collection: "+ mem1); for(int i=0; i<1000; i++) someints[i] = new Integer(i); // allocate integers… Read More »

Complex JSON String parsing in ANDROID

By | June 10, 2011

Hello all….. In the previous post I have shown you how to parse a Simple JSON String in ANDROID. In today’s tutorial I will show you how to parse a complex JSON String. Take a look at the example Here the JSON String used is [java] "{"menu": " "{"id": " ""file", "value": "File", "popup": " "{ "menuitem": [… Read More »

Program for Palindrome checking in C Sharp/C#

By | May 17, 2011

Hi, Sometimes you need to check for whether the given string is Palindrome or not. Given below is a sample code to check whether the given string is Palindrome or not using C Sharp/C#. [csharp] class Palindrome { static void Main() { string checkStr, sampleStr; char[] temp; System.Console.Write("Enter your String: "); sampleStr = System.Console.ReadLine(); checkStr = sampleStr.Replace(" ",… Read More »

Global variables in ANDROID……

By | May 17, 2011

Hi all……. In today’s exampl e I will show you how to deal with global variables in ANDROID. You know global variables are those variables that you can access across any variables. It’s value becomes changed when you change it in any of the classes in your project. These types of variables act as like cookies in a… Read More »

How to use Global variables in ANDROID?

By | May 17, 2011

Hi all……. In today’s exampl e I will show you how to deal with global variables in ANDROID. You know global variables are those variables that you can access across any variables. It’s value becomes changed when you change it in any of the classes in your project. These types of variables act as like cookies in a… Read More »

Copy a file in C Sharp/C# without using FileInfo

By | May 16, 2011

Hi, We have discussed here copying a file using FileInfo. Now we are going to see how we can do the same without using FileInfo in C Sharp/C#. [csharp] using System; using System.IO; class MainClass { public static void Main(string[] args) { int i; FileStream fileIn; FileStream fileOut; try { fileIn = new FileStream("opFile.txt", FileMode.Open); } catch(FileNotFoundException exc)… Read More »

Copying a file using FileInfo – C Sharp/C#

By | May 16, 2011

Hi, For copying a file using FileInfo in C Sharp/C#, use the following code. For copying a file without using file info check the example given here. [csharp] using System; using System.IO; public class MainClass { static void Main(string[] args) { FileInfo testFile = new FileInfo(@"c:NewWorkstestOld.txt"); testFile.Create(); testFile.CopyTo(@"c:NewProjtestNew.txt"); } } [/csharp] 🙂

C Sharp/C# – Writing to a text file

By | May 7, 2011

Hi, Use the following example code, if you want to write to a text file using C Sharp/C#. [csharp] using System; using System.IO; class MainClass { public static void Main() { FileStream trialStream = new FileStream("sampleText.txt", FileMode.Create); StreamWriter trialWrite = new StreamWriter(trialStream ); trialWrite.WriteLine("{0} {1}", "CoderzHeaven", 100); trialWrite.Close(); trialStream .Close(); } } [/csharp] 🙂

How to split a String in ANDROID?

By | May 5, 2011

Hi all….. Splitting a string in android is really easy.checkout the following snippet. [java] package com.coderzheaven; import android.app.Activity; import android.os.Bundle; public class SplitStringDemo extends Activity { String str = "India, USA, Japan, Russia, France"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String arr[] = str.split(","); for(int i = 0; i < arr.length; i++){ System.out.println("arr["+i+"] = " +… Read More »