Pages

Monday, 18 May 2015

Android Shared preferences

Shared preferences in android is very effective to handle session management and also for storing value for long time even if you close the application.
Following are simple code for shared preferences.
Note that you must commit the preferences for save the value.
It can be done with commit() method.

MainActivity.java.
package com.im.sharedpreferences;

import com.im.sharedpreferences.*;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends Activity {

TextView name ;
TextView phone;
TextView email;

public static final String MyPREFERENCES = "MyPrefs" ;
public static final String Name = "NAME";
public static final String Phone = "PHONE";
public static final String Email = "EMAIL";


SharedPreferences sharedpreferences;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

name = (TextView) findViewById(R.id.editTextName);
phone = (TextView) findViewById(R.id.editTextPhone);
email = (TextView) findViewById(R.id.editTextEmail);


sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);

if (sharedpreferences.contains(Name))
{
name.setText(sharedpreferences.getString(Name, ""));

}
if (sharedpreferences.contains(Phone))
{
phone.setText(sharedpreferences.getString(Phone, ""));

}
if (sharedpreferences.contains(Email))
{
email.setText(sharedpreferences.getString(Email, ""));

}
if (sharedpreferences.contains(Street))
{
street.setText(sharedpreferences.getString(Street, ""));

}
if (sharedpreferences.contains(Place))
{
place.setText(sharedpreferences.getString(Place,""));

}

}

public void run(View view){
String n = name.getText().toString();
String ph = phone.getText().toString();
String e = email.getText().toString();

Editor editor = sharedpreferences.edit();
editor.putString(NAME, n);
editor.putString(PHONE, ph);
editor.putString(EMAIL, e);


editor.commit();

}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

}
activiy_main.xml.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".DisplayContact" >

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="370dp"

>

<EditText
android:id="@+id/editTextName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="5dp"
android:layout_marginLeft="82dp"
android:ems="10"
android:inputType="text" >

</EditText>

<EditText
android:id="@+id/editTextEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:ems="10"
android:inputType="textEmailAddress" />



<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="28dp"
android:onClick="run"
android:text="@string/save" />



<EditText
android:id="@+id/editTextPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone|text" />

</RelativeLayout>

</ScrollView>


 AndroidManifest.xml.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.im.sharedpreferences"
android:versionCode="1"
android:versionName="1.0" >

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

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.im.sharedpreferences.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

</manifest>

Saturday, 18 April 2015

Human Arts.


Occasionally, human are creating new arts through them. Sometimes they makes tattoo or design on their body and present arts. From this kind of arts they also wants to convey message to society.

1. 


2. 


3. 



4.


5.

Friday, 17 April 2015

Wednesday, 8 April 2015

Fact about facebook that you dont know even if you are using it.

1. The reason Facebook is blue, is because Mark Zuckerberg is colorblind.


2. Facebook tracks and records almost everything you do on the internet if you’re logged in at the same time.

3. More than 600,000 hacking attempts are made on Facebook accounts every day.

4. It’s possible to change your Facebook language to “Pirate”.


5. Al Pacino was the first “face” on Facebook.


Content  Courtesy -Unbelievable facts 

Tuesday, 7 April 2015

India Pulls Off Great Escape in Yemen, 4000 Evacuated From War Zone


Mission Accomplished. The government is looking to wrap up Operation Raahat with almost all the estimated 4000 Indians in Yemen evacuated safely from the war zone.

The Indian Navy's INS Tarkash will reach Djibouti from Al Hodeidah with 74 people this morning and the INS Sumitra will reach Al Hodeidah, to ferry out one of the last batches. Air India will run its last evacuation flights from Yemeni capital Sana'a and the government has asked all Indians who want to leave to reach the capital.

On Monday, India rescued more than 1,000 people by plane and ship, the second time in two days that such a large number have been brought out since Saudi Arabia launched air strikes against Iran-allied Houthi rebels in Yemen on March 26. India has been asked by 26 nations - including the United States - to help get their citizens out of the conflict zone.

The Indian Navy Ship Mumbai, a premier warship, rescued nearly 1000 people from nine countries in two batches. Though not designed to ferry people, the Mumbai carried one and a half times the number of crew on board.

The crew emptied five messes and their cabins so that women and children got bunks to sleep on. Hot food was served and doctors were at hand.
 
Other warships, the INS Sumitra and the INS Tarkash have done a similar job across the coast of war-torn Yemen.

Sunday, 1 September 2013


STATE LEVEL SCIENCE, MATHEMATICS AND ENVIRONMENT EXHIBITION
FOR  CHILDREN–2013–14
and
41ST JAWAHARLAL NEHRU NATIONAL SCIENCE, MATHEMATICS AND
ENVIRONMENT  EXHIBITION FOR  CHILDREN–2014
G U I D E L I N E 

http://gcert.gujarat.gov.in/gcert/portal/news/22_1_Science_Fair_Guidelines%20English%202013-14.pdf



      Distance Education Program School List..

   click on following link to know about Distance Education Program School List..
 

 http://gcert.gujarat.gov.in/gcert/Portal/News/44_1_Distance_Education_Program_School_List_2013-       14.PDF