save an Android application's state and restore

The savedInstanceState way for saving state associated with a current instance of an Activity, for example - current navigation, selections, unsaved text.. etc, so that if Android destroys and recreates an Activity, it can come back as it was before.

We should override onSaveInstanceState(Bundle savedInstanceState) and write the application state values you want to change to the Bundle parameter like this:

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
  // Save UI state changes to the savedInstanceState.
  // This bundle will be passed to onCreate if the process is
  // killed and restarted.
  savedInstanceState.putBoolean("MyBoolean", true);
  savedInstanceState.putDouble("myDouble", 1.9);
  savedInstanceState.putInt("MyInt", 1);
  savedInstanceState.putString("MyString", "Welcome back to Android");
  // etc.
  super.onSaveInstanceState(savedInstanceState);
}

This stores the values into  Bundle in a NVP ("Name-Value Pair") map, and it will get passed in to onCreate and also onRestoreInstanceState.

Extract the values stored:

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
  super.onRestoreInstanceState(savedInstanceState);
  // Restore UI state from the savedInstanceState.
  // This bundle has also been passed to onCreate.
  boolean myBoolean = savedInstanceState.getBoolean("MyBoolean");
  double myDouble = savedInstanceState.getDouble("myDouble");
  int myInt = savedInstanceState.getInt("MyInt");
  String myString = savedInstanceState.getString("MyString");
}

Silence Removal and End Point Detection JAVA Code

For the purpose of silence removal of captured sound, we used the algorithm  in our final year project. In this post, I am publishing the endpoint detection and silence removal code ( implementation of this algorithm in JAVA).

These links might be useful to you as well.
The constructor of following java class EndPointDetection takes two parameters
  1. array of original signal's amplitude data : float[] originalSignal
  2. sampling rate of original signal in Hz : int samplingRate
The Java Code :
package org.ioe.tprsa.audio.preProcessings;

declare global variable in android- example code

To declare global variable in android, you need to 
1) create your own subclass of android.app.Application
2) and then specify that class in the application tag in your manifest. 
Android will automatically create an instance of that class and make it available for your entire application. You can access it from any context using the Context.getApplicationContext() method (Activity also provides a method getApplication() which has the exact same effect):
  • Sub Class of Application :
     public class MyApp extends Application {
           String foo;
      }
  • In the AndroidManifest.xml add android:name
 <application 
     android:icon="@drawable/icon" 
     android:label="@string/app_name" 
     android:name="com.company.MyApp">
  </application>

Full Example :

What's the difference between a primary key and a unique key?

Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where unique creates a non-clustered index by default. Another major difference is that, primary key does not allow NULLs, but unique key allows one NULL only.

What is de-normalization and when would you go for it?

As the name indicates, de-normalization is the reverse process of normalization. It is the controlled introduction of redundancy in to the database design. It helps improve the query performance as the number of joins could be reduced.

What are clustered index and non clustered index


With a clustered index the rows are stored physically on the disk in the same order as the index. There can therefore be only one clustered index.
With a non clustered index there is a second list that has pointers to the physical rows. You can have many non clustered indexes, although each new index will increase the time it takes to write new records.
It is generally faster to read from a clustered index if you want to get back all the columns. You do not have to go first to the index and then to the table.
Writing to a table with a clustered index can be slower, if there is a need to rearrange the data.
In other words,
A clustered index means you are telling the database to store close values actually close to one another on the disk. This has the benefit of rapid scan / retrieval of records falling into some range of clustered index values.


From Wikipedia :
database index is a data structure that improves the speed of data retrieval operations on a database table at the cost of slower writes and increased storage space

Silence Removal and End Point Detection MATLAB Code

Visit http://ganeshtiwaridotcomdotnp.blogspot.com/2011/06/final-report-text-prompted-remote.html for more detail about our project.
For the purpose of silence removal of captured sound, we used the algorithm specified in
"A New Silence Removal and Endpoint Detection Algorithm for Speech and Speaker Recognition Applications"
Our actual system was in JAVA but we verified the performance of this algorithm in MATLAB.

Inputs and Output
Before silence removal
After automatic silence removal
Here is the Matlab code : 
It first records sound for 5 seconds and removes the silence and then plays back.

Logic Design of Digital Clock, assignment on logic circuits

Logic Design of Digital Clock, assignment on logic circuits

Logic Design of Exhibition hall visitor density counter

Logic Design of Exhibition hall visitor density counter

History of UNIX like OS : Assignment Article

History of UNIX Like OS Assignment