Android Open Source - hts-cycle Name Activity






From Project

Back to project page hts-cycle.

License

The source code is released under:

GNU General Public License

If you think the Android project hts-cycle listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package it.uniroma2.wifionoff;
/*  w  ww .  ja  v a  2s . c  o m*/
import java.io.IOException;

import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class NameActivity extends Activity {

  private SQLiteDatabase database;
  private DataBaseHelper myDbHelper;
  private EditText name;
  private Button submitName;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_name);
    
    name = (EditText) findViewById(R.id.NAME);
    submitName = (Button) findViewById(R.id.SETNAME);
    

       
      try {myDbHelper.createDataBase();} 
        catch (IOException ioe) 
        {throw new Error("Unable to create database");}
       
      try {myDbHelper.openDataBase();}
        catch(SQLException sqle){throw sqle;}
      
      database=myDbHelper.getReadableDatabase();
    Cursor cursor;
    cursor = database.rawQuery(("select * from name"), null);
    cursor.moveToFirst();
    String Ric = new String();
    Ric=cursor.getString(cursor.getColumnIndex("name"));
    name.setText(Ric);
    database.close();
    
    submitName.setOnClickListener(new OnClickListener(){

      @Override
      public void onClick(View v) {
        // TODO Auto-generated method stub
        
        
        database=myDbHelper.getReadableDatabase();
        String clicked = name.getText().toString();    
        Cursor cursor;
        cursor = database.rawQuery(("select * from name"), null);
        cursor.moveToFirst();
        String Ric = new String();
        Ric=cursor.getString(cursor.getColumnIndex("name"));
        database.delete("name", "name = '"+Ric+"'", null);
        ContentValues values = new ContentValues();
        values.put("name",clicked );
        database.insert("name", null, values);
        cursor.close();
        database.close();
        
      }
      
      
      
      
    });
    
    
  }

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

}




Java Source Code List

it.uniroma2.musicsharep2p.DataBaseHelper.java
it.uniroma2.musicsharep2p.DefaultValue.java
it.uniroma2.musicsharep2p.DownloadActivity.java
it.uniroma2.musicsharep2p.MainActivity.java
it.uniroma2.musicsharep2p.MessengerService.java
it.uniroma2.musicsharep2p.MusicSettingActivity.java
it.uniroma2.musicsharep2p.MusicShutReceiver.java
it.uniroma2.musicsharep2p.PlayListActivity.java
it.uniroma2.musicsharep2p.RemoteServiceConnection.java
it.uniroma2.musicsharep2p.SongsManager.java
it.uniroma2.musicsharep2p.Utilities.java
it.uniroma2.wifionoff.AlarmReceiver.java
it.uniroma2.wifionoff.AppActivity.java
it.uniroma2.wifionoff.AppHelper.java
it.uniroma2.wifionoff.DataBaseHelper.java
it.uniroma2.wifionoff.IpMaker.java
it.uniroma2.wifionoff.MainActivity.java
it.uniroma2.wifionoff.MessageMaker.java
it.uniroma2.wifionoff.MyListActivity.java
it.uniroma2.wifionoff.NameActivity.java
it.uniroma2.wifionoff.OnOffService.java
it.uniroma2.wifionoff.PacketHandler.java
it.uniroma2.wifionoff.ServiceCall.java
it.uniroma2.wifionoff.SettingActivity.java
it.uniroma2.wifionoff.Setting.java
it.uniroma2.wifionoff.ShutDownReceiver.java
it.uniroma2.wifionoff.WifiConfigurationNew.java
it.uniroma2.wifionoff.WifiHandler.java
it.uniroma2.wifionoff.WifiManagerNew.java
it.uniroma2.wifionoff.WifiOffReceiver.java
it.uniroma2.wifionoff.WifiReceiver.java