Monday, August 11, 2014

Shared preference in android store data in internal memory at current time onside of app

In shared preference we can store data in internal memory of app at current time of PP 

THIS IS USE MORE AND  MORE IF WE HAVE need to store data email,password and some other information of that application 

code are as follows

Activity or User interface:-






Sharedprefrence.class

public class Sharedprefrence extends Activity{
EditText edtemail,edtfirstname;
Button btnsave,btnget;
TextView txtemail,txtfirstname;
String email,firstname;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sharedprefrence);
edtemail=(EditText)findViewById(R.id.editText1);
edtfirstname=(EditText)findViewById(R.id.editText2);
txtemail=(TextView)findViewById(R.id.textView1);
txtfirstname=(TextView)findViewById(R.id.textView2);
btnsave=(Button)findViewById(R.id.button1);
btnget=(Button)findViewById(R.id.button2);

final SharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", MODE_PRIVATE); 
   final Editor editor = pref.edit();
   btnsave.setOnClickListener(new OnClickListener() {
@SuppressLint("NewApi")
@Override
public void onClick(View v) { 
editor.putString("email", edtemail.getText().toString());
editor.putString("firstname", edtfirstname.getText().toString());
editor.commit();
}
});
btnget.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
email=  pref.getString("email", null); 
firstname=  pref.getString("firstname", null);
  txtemail.setText(email);
  txtfirstname.setText(firstname);
}
});
}
}


Manifest file changes:-

Add a service of storage

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



Thank you ..It may help you more.....

Sunday, August 3, 2014

Android Log how we use them . Log.v(), Log.d(), Log.i(), Log.w(), Log.e()

Basically Log are 5 kinds of Log those are describe in details:- 

Log.v(); // Verbose
Log.d(); // Debug
Log.i(); // Info
Log.w(); // Warning
Log.e(); // Error

Where
Log.v(String,String);
Log.d(String,String);
Log.i(String,String);
Log.w(String,String);
Log.e(String,String);


Log.e: This is for when bad stuff happens. Use this tag in places like inside a catch statement. You know and error has 
occurred and therefore you're logging an error.

Log.w: Use this when you suspect something shady is going on. You may not be completely 
in full on error mode, but maybe you recovered from some unexpected behavior. Basically,
 use this to log stuff you didn't expect to happen but isn't necessarily an error. Kind 
 of like a "hey, this happened, and it's weird, we should look into it."

Log.i: Use this to post useful information to the log. For example: that you have 
successfully connected to a server. Basically use it to report successes.

Log.d: Use this for debugging purposes. If you want to print out a bunch of messages
 so you can log the exact flow of your program, use this. If you want to keep a log of variable values, use this.

Log.v: Use this when you want to go absolutely nuts with your logging. If for some 
reason you've decided to log every little thing in a particular part of your app, use the Log.v tag.


Thank's  It may help you more.....






Friday, August 1, 2014

How to move check box Right side in android

Actually at this situation we make CheckTextView

and Preporty of CheckTextView are

<CheckedTextView
        android:id="@+id/chbCourse1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
          android:checkMark="?android:attr/listChoiceIndicatorMultiple"
        android:checked="false"
        android:gravity="center"
        android:layout_marginTop="30dp"
        android:textColor="#000000"
        android:text="Course1 " />

where as Check are in Right side you can implement this or make it in your as per need ....


Thank you ......

How to Remove titlebar in android or how to make all Activity or UI full schreen without title bar in android....

In manifest You have need update  single line of code which are

in side of application Tag

android:theme="@android:style/Theme.NoTitleBar"


full code :-In manifest update

 <application
        android:allowBackup="true"
        android:icon="@drawable/logo"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar" >
    
Now You have full screen UI without title bar in android ......

Thank you it may help you guise....