Friday, 20 March 2015
Android Page refresh in 20Seconds
Android Page refresh in 20 seconds
main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginLeft="23dp"
android:text="Button" />
</RelativeLayout>
---------------------------------------------------------------------------------
MainActivity-
package com.example.pagerefresh;
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
Handler handler;
Button b;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b=(Button)findViewById(R.id.button1);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "test", Toast.LENGTH_SHORT).show();
}
});
Toast.makeText(getApplicationContext(), "page refreshed", Toast.LENGTH_SHORT).show();
handler= new Handler();
handler.postDelayed(new Runnable(){
@Override
public void run() {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "hello1", Toast.LENGTH_SHORT).show();
Intent i=new Intent(MainActivity.this,MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
handler.removeCallbacksAndMessages(null);
handler.postDelayed(this, 4000);
}
}, 5000*4);//for 20sec
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
handler.removeCallbacksAndMessages(null);
super.onDestroy();
}
@Override
public void onStop() {
// TODO Auto-generated method stub
handler.removeCallbacksAndMessages(null);
super.onStop();
}
}
main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginLeft="23dp"
android:text="Button" />
</RelativeLayout>
---------------------------------------------------------------------------------
MainActivity-
package com.example.pagerefresh;
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
Handler handler;
Button b;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b=(Button)findViewById(R.id.button1);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "test", Toast.LENGTH_SHORT).show();
}
});
Toast.makeText(getApplicationContext(), "page refreshed", Toast.LENGTH_SHORT).show();
handler= new Handler();
handler.postDelayed(new Runnable(){
@Override
public void run() {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "hello1", Toast.LENGTH_SHORT).show();
Intent i=new Intent(MainActivity.this,MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
handler.removeCallbacksAndMessages(null);
handler.postDelayed(this, 4000);
}
}, 5000*4);//for 20sec
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
handler.removeCallbacksAndMessages(null);
super.onDestroy();
}
@Override
public void onStop() {
// TODO Auto-generated method stub
handler.removeCallbacksAndMessages(null);
super.onStop();
}
}
Thursday, 19 March 2015
Built-In Functions Of PostgreSQL
PostgreSQL built-in functions, also called as Aggregate functions,
are used for performing processing on string or numeric data. Following is the
list of all general purpose PostgreSQL built-in functions:
Functions
|
Description
|
COUNT
|
·
COUNT
aggregate function is used to count the number of rows in a database table.
|
MAX
|
MAX
aggregate function allows us to select the highest (maximum) value for a
certain column.
|
MIN
|
MIN
aggregate function allows us to select the lowest (minimum) value for a
certain column.
|
AVG
|
·
AVG
aggregate function selects the average value for certain table column.
|
SUM
|
·
SUM
aggregate function allows selecting the total for a numeric column.
|
ARRAY
|
ARRAY
aggregate function puts input values, including nulls, concatenated into an
array.
|
Numeric
|
Complete
list of PostgreSQL functions required to manipulate numbers in SQL.
|
String
|
·
Complete
list of PostgreSQL functions required to manipulate strings in PostgreSQL.
|
Oracle and PostgreSQL Query Difference
10 Major Oracle and PostgreSQL Query Difference
Oracle
|
PostgreSQL
|
select *
from tablename;
|
select *
from tablename;
|
desc
tablename
|
-----(select
itself desc coming)
|
nvl(sum,0)
|
coalesce(sum,0)
|
decode(a,1,aa,bb)
|
(case when
a=1 then aa else bb end)
|
oracle
supports ‘’ or null (both are same)
|
In
postgresql ‘’ and null both are
different
|
rownum
|
limit
|
rowed
|
ctid
|
Date shows
dd/mmm/yyyy
|
yyyy/mmm/dd
|
Auto cast
from String to Date
|
cast(d as
date)
|
String to
integer to_number(a)
|
cast ( a as
numeric)
|
Oracle Vs PostgreSQL -Which is Faster?
In
software industry if a project comes to engineer to develop first
thing comes in his mind which language to be use. And the second and most important
thing which database should use? There are several databases in market. Some
are paid and reaming open source. Many people go for open source because no
need to pay or invest huge amount. Oracle is the famous and most running
database in market which is a paid database. PostgreSQL is similar to Oracle
which is a open source database. Most of the operations of PostgreSQL are similar
to Oracle.
PostgreSQL
Oracle
The same query runs in PostgreSQL in 31ms (Miliseconds) and oracle in 55ms. In Oracle if we want to check its data type we have to type a command ‘DESC
TABLENAME’. But in PostgreSQL it is coming in ‘SELECT * FROM TABLE NAME’. Just
see the images above.Sunday, 15 March 2015
Features Of PostgreSQL
PostgreSQL is a powerful, open source object-relational
database system. Compare to oracle it fetches data quickly, And working very
speed on server level. Most of all the oracle built-in functions working in
PostgreSQL.
It has a strong reputation for reliability, data integrity,
and correctness. It runs on all major operating systems, including Linux, UNIX
(AIX, BSD, HP-UX, SGI IRIX, Mac OS X, Solaris, Tru64), and Windows. It is fully
ACID compliant, has full support for foreign keys, joins, views, triggers, and
stored procedures (in multiple languages). It includes most SQL:2008 data
types, including INTEGER, NUMERIC, BOOLEAN, CHAR, VARCHAR, DATE, INTERVAL, and
TIMESTAMP. It also supports storage of binary large objects, including
pictures, sounds, or video. It has native programming interfaces for C/C++,
Java, .Net, Perl, Python, Ruby, Tcl, ODBC, etc.
Features
PostgreSQL prides itself in standards compliance. Its SQL
implementation strongly conforms to the ANSI-SQL:2008 standard. It has full
support for subqueries (including subselects in the FROM clause),
read-committed and serializable transaction isolation levels. And while
PostgreSQL has a fully relational system catalog which itself supports multiple
schemas per database, its catalog is also accessible through the Information
Schema as defined in the SQL standard.
Data integrity features include (compound) primary keys,
foreign keys with restricting and cascading updates/deletes, check constraints,
unique constraints, and not null constraints.
It also has a host of extensions and advanced features.
Among the conveniences are auto-increment columns through sequences, and
LIMIT/OFFSET allowing the return of partial result sets. PostgreSQL supports
compound, unique, partial, and functional indexes which can use any of its
B-tree, R-tree, hash, or GiST storage methods.
PostgreSQL
runs stored procedures in more than 12 programming languages, including Java,
Perl, Python, Ruby, Tcl, C/C++, and its own PL/pgSQL, which is similar to
Oracle's PL/SQL. Included with its standard function library are hundreds of
built-in functions that range from basic math and string operations to
cryptography and Oracle compatibility. Triggers and stored procedures can be
written in C and loaded into the database as a library, allowing great
flexibility in extending its capabilities. Similarly, PostgreSQL includes a
framework that allows developers to define and create their own custom data
types along with supporting functions and operators that define their behavior.
As a result, a host of advanced data types have been created that range from
geometric and spatial primitives to network addresses to even ISBN/ISSN
(International Standard Book Number/International Standard Serial Number) data
types, all of which can be optionally added to the system.
Source: http://www.postgresql.org/
Subscribe to:
Posts (Atom)