Tag
%temp%
Android Application to understand Activity
Android Applicaton login button should remain disabled
Android Program
C Language GTU MCA Syllabus PPT/Notes
C full ppt by keval nagaria
C++ GTU MCA
CPI/CGPA To Percentage Calculator
Core JAVA GTU MCA
Core Java
Create Bootable USB flash Drive Using DISKPART utility
Create USB Pen Drive
Create an application that will create database with table of User credential.
Create an application that will have spinner with list of animation names. On selecting animation name
Create an application to call specific entered number by user in the EditText
Create an application to make Insert
Crimping
DBMS GTU MCA Syllabus PPT/Note
DISKPART
DOS Command to Erase temp file
DS GTU MCA
Delete and retrieve operation on the database.
Erase/Delete Temp file
Ethernet
FON GTU MCA
FON Practical Solution
FON Program
Fundamental Of Networking
GTU MCA PPT
GTU Student FInd CPI/CGPA To Percentage Converter
Intent
Java Chapter Wise Slide Show For GTU MCA Student Sem-3
LAN Cable
Online CPI/CGPA Converter/Calculator
PL_SQL GTU MCA Syllabus PPT/Note
RG45 Connector
Read messages from the mobile and display it on the screen.
SS(System Software) GTU MCA
Understand Menu option. a. Create an application that will change color of the screen
Understand resource folders : a. Create spinner with strings taken from resource folder b. On changing spinner value
WTAD GTU MCA
WTAD Practical Solution
Web Technology And Application Development (WTAD)
Windwos 7 USB Pen Drive
application that will play a media file from the memory car
application to send message between two emulators
based on selected options from the menu.
change image.
delete temp file into C drive
draw line on the screen as user drag his finger
gtu mca android program
open any URL inside the application and clicking on any link from that URl should not open Native browser but that URL should open the same screen.
read file from asset folder and copy it in memory card.
take picture using native application
that animation should affect on the images displayed below.
to pick up any image from the native application gallery and display it on the screen.
update
Utilities: 5 add-ons for graphic editing from the browser
A few weeks ago we decided to dedicate the section Utilities to improve the appearance of Mozilla Firefox, as supplements allow us to completely change it by giving some touches that will make your browser unique. This is just one example of what we can do because of additions and extensions of today's browsers, but they have not only evolved, but so has the media they consume: the web.
In just beginning pages of hypertext, the web of the XXI century has evolved to give us the possibility of, for example, make streaming music or consume hours and hours of movies and games without leaving the browser. Fortunately, not only has advanced in the entertainment field, and now the browser can be a tool to carry out, for example, buckslips, which is the subject on which I based the collection of profits from this week.
Sumo Paint
With Sumo Paint can enjoy creating, retouching or shared images from any modern browser. This is a Finnish service offering for some time a photo editor with more than 1 million active users a month and a community that contributes to the cause because of the social characteristics of the site.
Upon entering the page we find a publisher that gives the feeling of belonging to OS X and the access that besides the classical tools can adjust many aspects of the image and add filters, perhaps the greatest attraction of this first entry in the list, along with the fact that it is in perfect Spanish as well as a handful of languages, which appreciate the people who understand little English. Is the downside? It is based on Flash
to run.
Editor Pixlr
Pixlr Editor is an application for Chrome that provides a complete editor, ideal for quick editing you pictures. And I say ideal because it just will take some seconds after you press the install button until you are editing images. The description of the application itself informs us that are not necessary nor expected any downloads.
The interface we are very similar to Gimp or Photoshop, and its toolbar we will find the most used functions of both programs. Amazing how things have evolved so that today we have an application as completely and enjoy it in the form of streaming, say, without leaving the cloud at any time. Do not fail to take a look at the list of filters, including old known as tilt-shift or Gaussian blur, perfect for a touch to your images before using them in our publications.
Aviary Image Editor
Another excellent editor for fast browser from Google. Aviary Image Editor includes much delas Pixel features and provides an application with support for layers that gives us the ability to easily edit images or add advanced effects typical of desktop programs. Endorsed by more than 30 tools for editing and searching for a really useful resource, thanks also can import photos directly from most commonly used storage places.
Aviary is very easy to give that little touch to our photos before sharing or use, and to prove just need to install the application and launch it from the page of Chrome new tab or from the application launcher you have installed.
Slashup
Another Flash-based editor. With the ability to share our creations on sites such as Picasa, Flickr or Facebook itself, the highlights of this popular service is focused on providing the ability to edit multiple images at once, and do it with layers, Photoshop-style. After launching Slashup (click on the option Jump right in), we find a simple but fully valid editor for small editions and labels.
Are missing some additional filters, certainly a field where Sumo Paint, the other editor Flash, it is much better, but basically we want to edit images with pixel accuracy, Slashup is a good choice.
A few weeks ago we decided to dedicate the section Utilities to improve the appearance of Mozilla Firefox, as supplements allow us to completely change it by giving some touches that will make your browser unique. This is just one example of what we can do because of additions and extensions of today's browsers, but they have not only evolved, but so has the media they consume: the web.
In just beginning pages of hypertext, the web of the XXI century has evolved to give us the possibility of, for example, make streaming music or consume hours and hours of movies and games without leaving the browser. Fortunately, not only has advanced in the entertainment field, and now the browser can be a tool to carry out, for example, buckslips, which is the subject on which I based the collection of profits from this week.
Sumo Paint
With Sumo Paint can enjoy creating, retouching or shared images from any modern browser. This is a Finnish service offering for some time a photo editor with more than 1 million active users a month and a community that contributes to the cause because of the social characteristics of the site.
Upon entering the page we find a publisher that gives the feeling of belonging to OS X and the access that besides the classical tools can adjust many aspects of the image and add filters, perhaps the greatest attraction of this first entry in the list, along with the fact that it is in perfect Spanish as well as a handful of languages, which appreciate the people who understand little English. Is the downside? It is based on Flash
to run.
Editor Pixlr
Pixlr Editor is an application for Chrome that provides a complete editor, ideal for quick editing you pictures. And I say ideal because it just will take some seconds after you press the install button until you are editing images. The description of the application itself informs us that are not necessary nor expected any downloads.
The interface we are very similar to Gimp or Photoshop, and its toolbar we will find the most used functions of both programs. Amazing how things have evolved so that today we have an application as completely and enjoy it in the form of streaming, say, without leaving the cloud at any time. Do not fail to take a look at the list of filters, including old known as tilt-shift or Gaussian blur, perfect for a touch to your images before using them in our publications.
Aviary Image Editor
Another excellent editor for fast browser from Google. Aviary Image Editor includes much delas Pixel features and provides an application with support for layers that gives us the ability to easily edit images or add advanced effects typical of desktop programs. Endorsed by more than 30 tools for editing and searching for a really useful resource, thanks also can import photos directly from most commonly used storage places.
Aviary is very easy to give that little touch to our photos before sharing or use, and to prove just need to install the application and launch it from the page of Chrome new tab or from the application launcher you have installed.
Slashup
Another Flash-based editor. With the ability to share our creations on sites such as Picasa, Flickr or Facebook itself, the highlights of this popular service is focused on providing the ability to edit multiple images at once, and do it with layers, Photoshop-style. After launching Slashup (click on the option Jump right in), we find a simple but fully valid editor for small editions and labels.
Are missing some additional filters, certainly a field where Sumo Paint, the other editor Flash, it is much better, but basically we want to edit images with pixel accuracy, Slashup is a good choice.
Create Bootable USB flash Drive Using DISKPART utility
DISKPART is a command line utility that enables you to manage
disks. Functionalities of DISKPART are that creation of partition of a disk,
setting the partition activate, list of disk you find, clean the partition,
select listed disk, format the partition using NTFS (New Technology File
System) or FAT (File Allocation Table) with quick option and assign an
appropriate letter to your partition.
DISKPART is used to make a bootable USB Drive there is no
need to use any premium software to make a USB drive to bootable here there are
some simple step to create a bootable disk.
- Launch the DISKART utility by typing the “diskpart” command at the start menu. You will show the below dialog box in the system.
- Find the drive with the appropriate size as the “list disk” command like following.
- Type “Select disk 1” command where “1” is actually the corresponding number of your USB drive.
- Note: - Make sure you select the correct flash drives if you have more than one of the same sizes otherwise the data are lost.
- Type “clean” command to remove all partitions.
- To create a bootable partition type the “create partition primary” command.
- Active the USB flash type the “active” command.
- Note: - Format USB flash drive using NTFS (New Technology File System) or FAT (File Allocation Table) you may use the FAT32 to format the USB flash drive when the size of the USB flash drive is about 3gb otherwise you may select the NTFS. Use the “quick” parameter to format the USB flash drive quickly. You should not need a boot sector on a USB flash drive. Most of the motherboards allowed booting to USB flash drive.
- Type the command “format fs=ntfs quick” to format the USB flash drive.
- You need to assign driver letter to USB flash drive. Type the “assign” command to assign letter.
- You are done with DISKPART utility. Type the command “exit” to exit the utility.
- Copy all the content from windows 7 or windows XP installation DVD onto the USB flash drive (a simple drag and drop to do)
- Note: - I would not recommend you extracting directly from ISO file instead of extract the file and then copy the file into the USB flash drive. Make sure you do not put the files into the sub folder the drive will not boot.
How to Erase/Delete the windows temporary files folder using
DOS command
Windows stores the temporary file and folder in your system.
It is a collection of files and folder that you install software on your system
previously. This temporary file and folder contain an enormous amount of space.
Temporary file creates a trouble shot like system is slow down and sometime a
threat to the privacy of the user by the other users of the computer.
·
What is a temporary file?
The temporary file is created by
software for many reasons, like when you are downloading any document such as
DOC and PDF file, and the file is saved as a temp file while you are using it.
·
Are this temp file is dangerous for computer?
Normally the temp file is not dangerous
for computer until someone put malware and Trojan code into the system. Putting
too many files into temp folder they will affect on any computer operation.
·
How to you protect against temporary file?
Temp file can be deleted either
manually or by software. The manually you delete temp file using run disk
cleanup.
·
Step to run disk cleanup
§
Click on ‘Start’ menu
§
Click my computer
§
Right click on C drive and select properties
§
Click on general tab
§
Click the disk cleanup tab
§
A new dialog box appears on screen and select
the check box which temp file you want to delete.
§
Click yes to continue and finally click ok to
delete the temp file into your system.
Note: - you may give the
administrative permission to delete the file.
Or
§
Click on ‘Start’ menu
§
Click on run
§
Type the keyword ‘%temp%’ and hit enter
§
List of temp files will appear on the window
§
Select all the files and delete them.
·
Delete temp file using the software.
Rather than downloading any paid software for erasing temp files I
suggest you to create your own code with DOS command and save it for life time
in your system.
·
Step to create temp remover manually.
§
Click on ‘Start’ menu
§
Click on run command and type ‘notepad’ and hit
enter
§
Type the following line into notepad
§
Save file with the extension (.bat) like
temp_remover.bat
§
Put this file into your ‘startup’ folder.
Exercise : 20
Create an application
to open any URL inside the application and clicking on any link from that URl should
not open Native browser but that URL should open the same screen.
Screen Shot:
XML :
main.xml :
main.xml :
JAVA :
TwentyFourActivity.java :
package kmn.TwentyFour;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class TwentyFourActivity extends Activity
{ @Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.gtumcappt.com");
webView.setWebViewClient(new HelloWebViewClient());
}
}
HelloWebViewClient.java :
package kmn.TwentyFour;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class HelloWebViewClient extends WebViewClient
{ @Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
}
Exercise : 23
Create an application
to pick up any image from the native application gallery and display it on the screen.
Screen Shot:
XML :
main.xml :
main.xml :
JAVA :
TwentythreeActivity.java :
package kmn.Twentythree;
import java.io.File;
import java.io.FileInputStream;
import android.app.Activity;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.provider.MediaStore.Images.Media;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class TwentythreeActivity extends Activity
{
/** @author Y@@D **/
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try
{
String[] projection={Media.DISPLAY_NAME, Media.DATA, Media.SIZE};
Cursor c=managedQuery(Media.EXTERNAL_CONTENT_URI, projection, null, null, null);
ImageView ivImage=(ImageView)findViewById(R.id.myImg);
File file = null;
String imgName = null ;
if(c.getCount()>0)
{
while(c.moveToNext())
{
file=new File(c.getString(1)); //after completing loop, it take last image from native Gallery to display.
imgName=c.getString(0);
}
c.close();
FileInputStream fis=new FileInputStream(file);
byte[] buffer=new byte[fis.available()];
fis.read(buffer);
Bitmap bm=BitmapFactory.decodeByteArray(buffer, 0, buffer.length);
TextView txtTitle=(TextView)findViewById(R.id.txtTitle);
txtTitle.setText(imgName.toString());
ivImage.setImageBitmap(bm);
}
}
catch(Exception e)
{
Toast.makeText(TwentythreeActivity.this, "Error: "+e, Toast.LENGTH_LONG).show();
}
}
}
Step To store images on sdcard and
scanning in to the emulator.
1)click on push on file onto the
device button
2)now select the iamge an upload it
3)goto the "Dev Tools" on
your emulator and click on "Media Scanner".
4)now check your image in
"gallery"
5)run your program
Enjoy..........
Exercise : 22
Create an application
to take picture using native application.
Screen Shot:
XML :
main.xml :
JAVA :
TwentyTwoActivity.java :
package kmn.TwentyTwo;
import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
public class TwentyTwoActivity extends Activity
{
/** @author Y@@D */
String path;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
path = Environment.getExternalStorageDirectory() + File.separator + "make_machine_example.jpg";
File file = new File( path );
Uri outputFileUri = Uri.fromFile( file );
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
startActivityForResult( intent, 0 );
}
}
Exercise : 21
Create an application
to send message between two emulators.
Screen Shot:
XML :
main.xml :
JAVA :
TwentyOneActivity.java :
package kmn.TwentyOne;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class TwentyOneActivity extends Activity
{
/** @author Y@@D */
Button btnSendSMS;
EditText txtPhoneNo;
EditText txtMessage;
//@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnSendSMS = (Button) findViewById(R.id.btnSendSMS);
txtPhoneNo = (EditText) findViewById(R.id.txtPhoneNo);
txtMessage = (EditText) findViewById(R.id.txtMessage);
/*
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "Content of the SMS goes here...");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
*/
btnSendSMS.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
String phoneNo = txtPhoneNo.getText().toString();
String message = txtMessage.getText().toString();
if (phoneNo.length()>0 && message.length()>0)
sendSMS(phoneNo, message);
else
Toast.makeText(getBaseContext(),"Please enter both phone number and message.", Toast.LENGTH_SHORT).show();
}
});
}
//---sends a SMS message to another device---
private void sendSMS(String phoneNumber, String message)
{
String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT),0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0);
//---when the SMS has been sent---
registerReceiver(new BroadcastReceiver()
{
// @Override
public void onReceive(Context arg0, Intent arg1)
{
switch (getResultCode())
{
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS sent",Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(getBaseContext(), "Generic failure", Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(getBaseContext(), "No service",Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(getBaseContext(), "Null PDU",Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(getBaseContext(), "Radio off",Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(SENT));
//---when the SMS has been delivered---
registerReceiver(new BroadcastReceiver()
{
//@Override
public void onReceive(Context arg0, Intent arg1)
{
switch (getResultCode())
{
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS delivered", Toast.LENGTH_SHORT).show();
break;
case Activity.RESULT_CANCELED:
Toast.makeText(getBaseContext(), "SMS not delivered", Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(DELIVERED));
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
}
}
SmsReceiver.java :
package kmn.TwentyOne;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.widget.Toast;
public class SmsReceiver extends BroadcastReceiver
{
/** @author Y@@D */
//@Override
public void onReceive(Context context, Intent intent)
{
//---get the SMS message passed in---
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
if (bundle != null)
{
//---retrieve the SMS message received---
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i=0; i
Step to Creat two emulator and send
sms.
1)goto windows->Android SDK and
AVD Mangaer.
2)creat two emulator and give the
different name.
3)start emulator by clicking start
button
3)now enter the emulator number to
phone number and send it.
Note:- see the give OutPut Image..
Enjoy.........
Exercise : 20
Create an application
to draw line on the screen as user drag his finger.
Screen Shot:
XML :
main.xml :
main.xml :
JAVA :
TwentyActivity.java :
package kmn.Twenty;
import android.app.Activity;
import android.os.Bundle;
public class TwentyActivity extends Activity
{
/** @author Y@@D */
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
setContentView(new ExploreTouchEvent(this, null));
}
}
ExploreTouchEvent.java :
package kmn.Twenty;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
/** @author Y@@D */
public class ExploreTouchEvent extends View
{
private Paint paint = new Paint();
private Path path = new Path();
public ExploreTouchEvent(Context context, AttributeSet attrs)
{
super(context, attrs);
paint.setAntiAlias(true);
paint.setStrokeWidth(6f);
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeJoin(Paint.Join.ROUND);
}
protected void onDraw(Canvas canvas)
{
canvas.drawColor(Color.BLUE);
canvas.drawPath(path, paint);
}
public boolean onTouchEvent(MotionEvent event)
{
float eventX = event.getX();
float eventY = event.getY();
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
path.moveTo(eventX, eventY);
return true;
case MotionEvent.ACTION_MOVE:
path.lineTo(eventX, eventY);
break;
case MotionEvent.ACTION_UP:
// nothing to do
break;
default:
return false;
}
// Schedules a repaint.
invalidate();
return true;
}
}
Crimping Ethernet/utp Cable: requires Minimum Items and Save
Money
‘Crimping’ is the process of
turning unshielded twisted pair cable to high quality LAN cable which can
be used to connect Computers, Switches, Modems and Router. This process is
quite easy but is charged heavily by shops. Wired network is more secure and easily
configured as compared to wireless network. By following the baby process
below, you can save up to 50 dollars and many more in lifetime. This hub will
reap you benefit for long time.
Items Required
There are 3 vital items required in the process: Crimping tool,
unshielded twisted pair Cable and registered jack 45 Connector. In
addition to the above items there are luxurious items such as Stripper, Tester
and Cutter. By following this you will generate similar high quality cable with
least efforts and Items.
Step -1:
Isolate the jacket of cable by using Crimping tool. If you have
stripper you can use it but as I described it is luxurious items. Start by
marking off 2 inch if you are a beginner. But when you have practiced well you
can do it without marking. Use the crimping tool carefully as we don’t want to
cut the inner wire. For beginners use tool lightly so that only slight cable is
scratched from that side. Then take the tool to the other side. Repeat this
process for the remaining side.
Step-2:
Spread the wires by holding the base of jacket so it does not
become untwisted inside the jacket. Extending the wire will give an added
advantage of arranging the cable into proper order.
Step-3:
Arrange the wire into a proper order. We have to make 4 pair of
wires from the 8 wires in the cable. We have to maintain a similar color coding
if we want to make a Crossover cable. Crossover Cable is used to
connect devices with similar function. If we want to connect two switches or
two computers we will use this kind of cable. Straight Cable is used to connect
devices with dissimilar function. If we want to connect PC to Computer we will
use this type of Cable. I am featuring the color coding with text and Image.
White Orange Orange, White Green Blue, White Blue Green, White
Brown Brown.
Step-4:
Arrange the 8 wires into 8 sides of the registered
jack 45 connectors. Look carefully from the top as you must see all the
trails of 8 wires. Use the video to locate connector in crimping tool and press
it once. The cable will produce a noise. Your cable is done.
Labels: Crimping, Ethernet, LAN Cable, RG45 Connector
CPI/CGPA To Percentage Converter
Formula for conversation of the equivalent of CPI/CGPA
For GTU student find CPI/CGPA equivalent to the percentage The formula is given below.
CPI/CGPA The class should be given by below ratio.
Formula for conversation of the equivalent of CPI/CGPA
For GTU student find CPI/CGPA equivalent to the percentage The formula is given below.
Percentage
Marks = (CPI/CGPA-0.5) * 10
Below 5.5
|
Pass Class
|
5.5 &
Above
|
Second Class
|
6.5 &
Above
|
First Class
|
7.1 &
Above
|
First Class
With Distinction
|
Award Of Degree
For all Courses, where the duration of the course is two years, students may find them Percentage on the basis of the CPI Cumulative Performance Index). If the course Duration is three or more than three they may find the percentage on the basis Of the CGPA (Cumulative Grade Point Average).
All the GTU Student calculates CPI/CGPA to percentage in online using the given calculator.
Here I made one Simple CPI/CGPA To Percentage Online Converter/Calculator..
Screen Shot :
For all Courses, where the duration of the course is two years, students may find them Percentage on the basis of the CPI Cumulative Performance Index). If the course Duration is three or more than three they may find the percentage on the basis Of the CGPA (Cumulative Grade Point Average).
All the GTU Student calculates CPI/CGPA to percentage in online using the given calculator.
Here I made one Simple CPI/CGPA To Percentage Online Converter/Calculator..
Screen Shot :
Exercise : 18
Create an application to make Insert , update ,
Delete and retrieve operation on the database.
Screen Shot:
XML :
main.xml :
search.xml :
JAVA :
EighteenActivity.java :
package kmn.Eighteen;
import java.util.Locale;
import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class EighteenActivity extends Activity
{
/** @author Y@@D * */
SQLiteDatabase db;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
createDB();
//do insert
Button btnInsert=(Button)findViewById(R.id.btnInsert );
btnInsert.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0)
{
insert();
}
});
Button btnClear=(Button)findViewById(R.id.btnClear );
btnClear.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0)
{
clear();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
CreateMenu(menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
return MenuChoice(item);
}
private void CreateMenu(Menu menu)
{
MenuItem mnu1 = menu.add(0, 0, 0, "Insert");
{
mnu1.setAlphabeticShortcut('i');
}
MenuItem mnu2 = menu.add(0, 1, 1, "Search");
{
mnu2.setAlphabeticShortcut('s');
}
MenuItem mnu3 = menu.add(0, 2, 2, "Delete");
{
mnu3.setAlphabeticShortcut('d');
//mnu3.setIcon(R.drawable.icon);
}
MenuItem mnu4 = menu.add(0, 3, 3, "View");
{
mnu4.setAlphabeticShortcut('d');
//mnu3.setIcon(R.drawable.icon);
}
}
private boolean MenuChoice(MenuItem item)
{
Intent intent=new Intent();
switch (item.getItemId())
{
case 0:
insert();
return true;
case 1:
intent.setClass(EighteenActivity.this, Search.class);
startActivity(intent);
return true;
case 2:
// intent.setClass(E18Activity.this, SelectRecord.class);
startActivity(intent);
return true;
case 3:
intent.setClass(EighteenActivity.this, ViewRecord.class);
startActivity(intent);
return true;
}
return false;
}
public void createDB()
{
db=openOrCreateDatabase("Student.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
db.setLocale(Locale.getDefault());
db.setLockingEnabled(true);
db.setVersion(1);
String sql="create table if not exists Stud(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER)";
db.execSQL(sql);
}
public void insert()
{
EditText txtName=(EditText)findViewById(R.id.txtName);
EditText txtAge=(EditText)findViewById(R.id.txtAge);
if(txtName.getText().toString().equals(""))
{
Toast.makeText(EighteenActivity.this, "Enter Name.", Toast.LENGTH_SHORT).show();
}
else if (txtAge.getText().toString().equals(""))
{
Toast.makeText(EighteenActivity.this, "Enter Age.", Toast.LENGTH_SHORT).show();
}
else
{
String sql="insert into Stud(name,age) values('"+ txtName.getText().toString() +"',"+txtAge.getText().toString()+")";
db.execSQL(sql);
clear();
Toast.makeText(EighteenActivity.this, "Record Successfully Inserted.", Toast.LENGTH_SHORT).show();
}
}
public void clear()
{
EditText txtName=(EditText)findViewById(R.id.txtName);
EditText txtAge=(EditText)findViewById(R.id.txtAge);
txtName.setText("");
txtAge.setText("");
txtName.clearFocus();
txtAge.clearFocus();
txtName.requestFocus();
}
@Override
public void onDestroy()
{
super.onDestroy();
db.close();
}
}
Search.java :
package kmn.Eighteen;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.Toast;
/** @author Y@@D * */
public class Search extends Activity
{
SQLiteDatabase db;
EditText txtSearch;
EditText txtName;
EditText txtAge;
Button btnEdit;
Button btnDelete;
RelativeLayout rlRecord;
RelativeLayout rlSearch;
String recID="0";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
db=openOrCreateDatabase("Student.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
txtName = (EditText)findViewById(R.id.txtName);
txtAge = (EditText)findViewById(R.id.txtAge);
txtSearch = (EditText)findViewById(R.id.txtSearch);
btnEdit=(Button)findViewById(R.id.btnEdit);
btnDelete=(Button)findViewById(R.id.btnDelete);
txtSearch.requestFocus();
txtName.setEnabled(false);
txtAge.setEnabled(false);
btnEdit.setEnabled(false);
btnDelete.setEnabled(false);
Button btnSearch=(Button)findViewById(R.id.btnSearch);
btnSearch.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0) {
if (txtSearch.getText().toString().equals(""))
{
Toast.makeText(Search.this, "Enter value.", Toast.LENGTH_SHORT).show();
}
else
{
searchRecord();
}
}
});
//---------------Edit/update---------------------------------
final Button btnEdit=(Button)findViewById(R.id.btnEdit);
btnEdit.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0)
{
if (btnEdit.getText().toString().equals("Edit"))
{
btnEdit.setText("Update");
txtName.setEnabled(true);
txtAge.setEnabled(true);
txtName.requestFocus();
btnDelete.setEnabled(false);
}
else
{
txtName.setEnabled(false);
txtAge.setEnabled(false);
btnDelete.setEnabled(true);
btnEdit.setText("Edit");
String sql="update Stud set name='"+txtName.getText().toString()+"', age="+txtAge.getText().toString()+" where id="+recID;
db.execSQL(sql);
Toast.makeText(Search.this, " Record Updated Successfully" , Toast.LENGTH_LONG).show();
}
}
});
//------------------------Delete ---------------------------
btnDelete.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0)
{
// TODO Auto-generated method stub
AlertDialog.Builder alertbox = new AlertDialog.Builder(arg0.getContext());
alertbox.setIcon(android.R.drawable.ic_dialog_alert);
alertbox.setTitle("Confirm");
alertbox.setMessage("Are You Sure? You want to delete this record");
alertbox.setPositiveButton("Delete", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface arg0, int arg1)
{
// TODO Auto-generated method stub
String sql="Delete from Stud where id="+recID;
db.execSQL(sql);
Toast.makeText(getApplicationContext(), "Record Deleted", Toast.LENGTH_LONG).show();
//clear old search result
txtSearch.setText("");
txtName.setText("");
txtAge.setText("");
txtSearch.requestFocus();
}
});
alertbox.setNegativeButton(" Cancel ", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface arg0, int arg1)
{
// TODO Auto-generated method stub
}
});
alertbox.show();
}
});
}
public void searchRecord()
{
try
{
txtSearch = (EditText)findViewById(R.id.txtSearch);
txtName = (EditText)findViewById(R.id.txtName);
txtAge = (EditText)findViewById(R.id.txtAge);
Cursor c=db.rawQuery("select id,name,age from Stud where id="+ txtSearch.getText().toString(), null);
if(c.getCount()>0)
{
c.moveToNext();
recID= c.getString(0);
txtName.setText( c.getString(1));
txtAge.setText(c.getString(2));
btnEdit.setEnabled(true);
btnDelete.setEnabled(true);
}
else
{
Toast.makeText(this, "No Record Found" , Toast.LENGTH_LONG).show();
}
}
catch(Exception e)
{
Toast.makeText(this, ""+e, Toast.LENGTH_LONG).show();
}
}
public void onDestroy()
{
super.onDestroy();
db.close();
}
}
ViewRecord.java :
package kmn.Eighteen;
/** @author Y@@D **/
import java.util.ArrayList;
import android.app.ListActivity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Toast;
public class ViewRecord extends ListActivity
{
SQLiteDatabase db;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
try
{
db=openOrCreateDatabase("Student.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
Cursor c=db.rawQuery("select id,name,age from Stud", null);
ArrayList list = new ArrayList();
int count=c.getCount();
if(c.getCount()>0)
{
while(c.moveToNext())
{
list.add(c.getString(0)+" , "+c.getString(1)+" , "+c.getString(2));
}
c.close();
Toast.makeText(this,"Total Records: "+count, Toast.LENGTH_LONG).show();
ArrayAdapter adapter=new ArrayAdapter(this,android.R.layout.simple_list_item_1, list);
getListView().setAdapter(adapter);
}
else
{
Toast.makeText(this, "No Record Found" , Toast.LENGTH_LONG).show();
}
}
catch(Exception e)
{
Toast.makeText(this, ""+e, Toast.LENGTH_LONG).show();
}
}
public void onDestroy()
{
super.onDestroy();
db.close();
}
}






















