LISTING PROGRAM
1. UserSettingActivity.java
package com.yudhi.lock;import java.io.File;
import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList;
import android.app.Activity; import android.app.AlertDialog;
import android.content.ActivityNotFoundException; import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences; import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.net.Uri;
import android.os.Bundle; import android.os.Environment;
import android.preference.PreferenceActivity; import android.preference.PreferenceManager; import android.provider.MediaStore;
import android.speech.RecognizerIntent; import android.text.InputType;
import android.view.Menu; import android.view.MenuItem; import android.view.View;
import android.view.View.OnClickListener; import android.widget.*;
public class UserSettingActivity extends Activity { private static final int SELECT_PICTURE = 1; private String selectedImagePath;
EditText ePass, eBg; Button btnChange; String pass, suara; DatabaseManager dm;
@Override
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); dm = new DatabaseManager(this);
btnChange = (Button)findViewById(R.id.btnChange); //if(ePass.getText().length()!=0){
startService(new Intent(this,MyService.class)); // Toast.makeText(getBaseContext(), "Lock actvated!", Toast.LENGTH_LONG).show();
//}
dm.open();
Cursor c = dm.getPass(1); if(c!=null && c.moveToFirst()){
ePass.setText(c.getString(1)); }
Cursor cc = dm.getOne(1);
if(cc!=null && cc.moveToFirst()){ eBg.setText(cc.getString(1)); }
dm.close();
ePass.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub Intent intent = new Intent(
RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "id-ID"); try {
startActivityForResult(intent, 0);
} catch (ActivityNotFoundException a) {
Toast.makeText(getBaseContext(),"Perangkat Tidak Mendukung",Toast.LENGTH_SHORT).show();
}
}
});
btnChange.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub Intent intent = new Intent(); intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE);
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) { case 0: {
getBaseContext();
if (resultCode == Activity.RESULT_OK && null != data) { ArrayList<String> text =
data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
suara = new String(text.get(0)); dm.open();
Cursor c = dm.getPass(1); if(c!=null && c.moveToFirst()){
dm.updatePass(1, suara); Cursor cPass = dm.getPass(1); ePass.setText(cPass.getString(1)); //startService(new
Intent(this,MyService.class));
//Toast.makeText(getBaseContext(), "Lock activated!", Toast.LENGTH_LONG).show();
}else{
dm.insertPass(suara);
Cursor cPass = dm.getPass(1); ePass.setText(cPass.getString(1)); //startService(new
Intent(this,MyService.class));
//Toast.makeText(getBaseContext(), "Lock actvated!", Toast.LENGTH_LONG).show();
}
dm.close(); }
break; }
case 1: {
getBaseContext();
if (resultCode == Activity.RESULT_OK && null != data) { Uri selectedImageUri = data.getData();
selectedImagePath = getPath(selectedImageUri); dm.open();
Cursor ccc = dm.getOne(1);
if(ccc!=null && ccc.moveToFirst()){
dm.updateRecord(1, selectedImagePath); Cursor c1 = dm.getOne(1);
eBg.setText(c1.getString(1));
}else{
dm.insertOne(selectedImagePath); Cursor c1 = dm.getOne(1);
eBg.setText(c1.getString(1));
//startService(new Intent(this,MyService.class));
}
ccc.close(); dm.close();
} break; }
} }
public String getPath(Uri uri) { if( uri == null ) {
// TODO perform some logging or show user feedback return null;
}
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null); if( cursor != null ){
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst();
return cursor.getString(column_index); }
// this is our fallback here return uri.getPath();
}
@Override
public void onBackPressed() {
// Do Here what ever you want do on back press; if(ePass.getText().length()==0){
final AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Gagal Menjalankan LockScreen"); alert.setMessage("Keluar Program?");
alert.setPositiveButton("Ya", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Do something with value! finish();
} });
alert.setNegativeButton("Batal", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled. }
});
alert.show();
}else{
startService(new Intent(this,MyService.class)); Intent a = new Intent(Intent.ACTION_MAIN); a.addCategory(Intent.CATEGORY_HOME); a.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(a);
}
}
}
2. Myservice.java
package com.yudhi.lock;
import receiver.lockScreenReeiver; import android.app.KeyguardManager; import android.app.Service;
import android.content.BroadcastReceiver; import android.content.Intent;
import android.content.IntentFilter; import android.os.Bundle;
import android.os.IBinder;
import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.view.WindowManager;
import android.widget.Toast;
public class MyService extends Service{ BroadcastReceiver mReceiver; // Intent myIntent;
@Override
public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null;
}
@Override
public void onCreate() {
//getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|Window Manager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
KeyguardManager km
=(KeyguardManager)getSystemService(KEYGUARD_SERVICE); k1= km.newKeyguardLock("IN");
k1.disableKeyguard();
/*try{
StateListener phoneStateListener = new StateListener(); TelephonyManager telephonyManager
=(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
telephonyManager.listen(phoneStateListener,PhoneStateListener.LISTEN_CALL_ST ATE);
}catch(Exception e){
System.out.println(e); }*/
/* myIntent = new Intent(MyService.this,LockScreenAppActivity.class); myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle myKillerBundle = new Bundle(); myKillerBundle.putInt("kill",1); myIntent.putExtras(myKillerBundle);*/
IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF);
mReceiver = new lockScreenReeiver(); registerReceiver(mReceiver, filter);
super.onCreate();
}
@Override
public void onStart(Intent intent, int startId) { // TODO Auto-generated method stub
super.onStart(intent, startId); }
/*class StateListener extends PhoneStateListener{ @Override
public void onCallStateChanged(int state, String incomingNumber) {
case TelephonyManager.CALL_STATE_RINGING: break;
case TelephonyManager.CALL_STATE_OFFHOOK:
System.out.println("call Activity off hook"); getApplication().startActivity(myIntent);
break;
case TelephonyManager.CALL_STATE_IDLE: break;
} } };*/
@Override
public void onDestroy() {
unregisterReceiver(mReceiver); super.onDestroy();
} }
3. Lock.java
package com.yudhi.lock;
import receiver.lockScreenReeiver; import android.net.ConnectivityManager; import android.net.NetworkInfo;
import android.os.Bundle; import android.os.Handler; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context;
import android.content.DialogInterface; import android.content.Intent;
import android.database.Cursor;
import android.graphics.drawable.Drawable; import android.speech.RecognitionListener; import android.speech.RecognizerIntent; import android.speech.SpeechRecognizer; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.text.InputType;
import android.util.Log; import android.view.Menu; import android.widget.*; import android.view.KeyEvent; import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import java.lang.Thread; import java.util.ArrayList; import java.util.HashMap;
public class Lock extends Activity { Button btnOpen, btnPass;
CheckBox cb; TextView txt1; String pass, suara; DatabaseManager dm; RelativeLayout rl; Dialog dialog;
private SpeechRecognizer sr;
private static final String TAG = "speech";
@Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,Wi ndowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.lock); final Animation animRotate = AnimationUtils.loadAnimation(this,
R.anim.anim_rotate); final Animation animTranslate = AnimationUtils.loadAnimation(this,
R.anim.anim_translate); final Animation animAlpha =
AnimationUtils.loadAnimation(this,
R.anim.anim_alpha); final Animation animScale = AnimationUtils.loadAnimation(this,
R.anim.anim_scale);
dialog = new Dialog(Lock.this); dm = new DatabaseManager(this);
btnOpen = (Button)findViewById(R.id.btn1); btnPass = (Button)findViewById(R.id.btnPass); AnalogClock ac = (AnalogClock)
findViewById(R.id.analogClock1);
//cb = (CheckBox)findViewById(R.id.cBoxClock); //txt1 = (TextView)findViewById(R.id.txt1);
//txt1.setVisibility(View.GONE);
rl = (RelativeLayout)findViewById(R.id.rl);
sr = SpeechRecognizer.createSpeechRecognizer(this); sr.setRecognitionListener(listener);
btnPass.setVisibility(View.INVISIBLE);
dm.open();
Cursor c = dm.getOne(1);
if(c!=null && c.moveToFirst()){
String ImagePath = c.getString(1).toString();
rl.setBackgroundDrawable(Drawable.createFromPath(ImagePath)); }else{
rl.setBackgroundResource(R.drawable.bg); }
dm.close();
try{
// initialize receiver
//startService(new Intent(this,MyService.class));
StateListener phoneStateListener = new StateListener();
TelephonyManager telephonyManager =(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
telephonyManager.listen(phoneStateListener,PhoneStateListener.LISTEN_ CALL_STATE);
}catch (Exception e) {
// TODO: handle exception }
btnOpen.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View view) {
// Intent intent = new Intent(
//
RecognizerIntent.ACTION_RECOGNIZE_SPEECH); //
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US");
// try {
//
startActivityForResult(intent, 1);
// } catch
(ActivityNotFoundException a) { //
// }
//btnOpen.setText("Listening.."); view.startAnimation(animRotate);
dialog.setContentView(R.layout.dialog); dialog.setTitle("Sedang mendengarkan.."); TextView text = (TextView)
dialog.findViewById(R.id.textDialog);
text.setText("Ucapkan!"); ImageView image = (ImageView) dialog.findViewById(R.id.imageDialog);
image.setImageResource(R.drawable.voice); dialog.show();
Button declineButton = (Button) dialog.findViewById(R.id.declineButton);
// if decline button is clicked, close the custom dialog
declineButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) { // Close dialog
dialog.dismiss(); }
});
Intent intent = new
Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "id-ID");
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,1);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"com.yudhi.loc k");
sr.startListening(intent);
} });
btnPass.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
AnimationSet sets = new AnimationSet(false); sets.addAnimation(animAlpha);
sets.addAnimation(animScale); sets.addAnimation(animRotate); v.startAnimation(sets);
final AlertDialog.Builder alert = new AlertDialog.Builder(Lock.this);
// Set an EditText view to get user input
final EditText input = new EditText(Lock.this); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
alert.setView(input);
alert.setPositiveButton("Open", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString(); dm.open();
Cursor cc = dm.getPass(1);
if(value.equalsIgnoreCase(cc.getString(1).toString())){ Intent a = new
Intent(Intent.ACTION_MAIN);
a.addCategory(Intent.CATEGORY_HOME);
a.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(a); finish();
}else{
alert.setMessage("Password Salah!");
input.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_wrong, 0);
}
dm.close();
// Do something with value! }
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled. }
});
alert.show();
}
});
}
Drawable getMyDrawable(Context c,String ImageName) { return
c.getResources().getDrawable(c.getResources().getIdentifier(ImageName , "drawable", c.getPackageName()));
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) { case 1: {
getBaseContext();
if (resultCode == Activity.RESULT_OK && null != data) {
// ArrayList<String> text =
data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
// suara = new String(text.get(0));
// dm.open();
// Cursor ccc = dm.getPass(1);
//
if(suara.equalsIgnoreCase(ccc.getString(1).toString())){
// Intent a = new Intent(Intent.ACTION_MAIN);
// a.addCategory(Intent.CATEGORY_HOME);
// a.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// startActivity(a);
// finish();
// }else{
// Toast.makeText(getBaseContext(), "Password
Salah!", Toast.LENGTH_LONG).show();
// }
//
// dm.close();
} break; }
} }
class MyRecognitionListener implements RecognitionListener {
public void onReadyForSpeech(Bundle params) {
Log.d(TAG, "onReadyForSpeech"); }
public void onBeginningOfSpeech() {
Log.d(TAG, "onBeginningOfSpeech"); }
public void onRmsChanged(float rmsdB) {
Log.d(TAG, "onRmsChanged"); }
public void onBufferReceived(byte[] buffer) {
Log.d(TAG, "onBufferReceived"); }
Log.d(TAG, "onEndofSpeech"); }
public void onError(int error) {
Log.d(TAG, "error " + error); if(dialog.isShowing()){
dialog.dismiss(); }
Toast.makeText(getBaseContext(), "Connection not Available, use Emergency Button to Open!",
Toast.LENGTH_LONG).show();
btnOpen.setVisibility(View.INVISIBLE); btnPass.setVisibility(View.VISIBLE);
}
public void onResults(Bundle results) {
String str = new String();
Log.d(TAG, "onResults " + results); ArrayList data =
results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); for (int i = 0; i < data.size(); i++) {
Log.d(TAG, "result " + data.get(0));
str = data.get(0).toString(); }
suara = new String(str); dm.open();
Cursor ccc = dm.getPass(1);
if(suara.equalsIgnoreCase(ccc.getString(1).toString())){ "Password Salah!= "+suara, Toast.LENGTH_LONG).show();
}
dm.close();
//Toast.makeText(getBaseContext(), ""+suara, Toast.LENGTH_LONG).show();
}
public void onPartialResults(Bundle partialResults) {
}
public void onEvent(int eventType, Bundle params) {
Log.d(TAG, "onEvent " + eventType); }
}
class StateListener extends PhoneStateListener{ @Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber); switch(state){
case TelephonyManager.CALL_STATE_RINGING: break;
case TelephonyManager.CALL_STATE_OFFHOOK:
System.out.println("call Activity off hook"); finish();
break;
case TelephonyManager.CALL_STATE_IDLE: break;
} } };
@Override
public void onStop() { super.onStop();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu); return true;
}
@Override
public void onBackPressed() {
// Do Here what ever you want do on back press; }
//
@Override
public void onAttachedToWindow() { // TODO Auto-generated method stub
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); super.onAttachedToWindow();
} //
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH &&
event.getRepeatCount() == 0) { return true;
}else if(keyCode == KeyEvent.KEYCODE_HOME){ Log.i("Home Button","Clicked");
}
return false; }
}
4. StartLockScreen.java
package com.yudhi.lock;import android.app.Activity;
import android.app.KeyguardManager; import android.content.Intent; import android.os.Bundle;
import android.view.WindowManager;
public class StartLockScreen extends Activity { /* KeyguardManager.KeyguardLock k1;
public void onAttachedToWindow() {
// TODO Auto-generated method stub
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); super.onAttachedToWindow();
}*/ @Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
startService(new Intent(this,MyService.class)); finish();
/*getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|Wi ndowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
KeyguardManager km
=(KeyguardManager)getSystemService(KEYGUARD_SERVICE); k1 = km.newKeyguardLock("IN");
k1.disableKeyguard();*/
}
5. lockScreenReeiver.java
package receiver;
import android.app.KeyguardManager; import android.content.BroadcastReceiver; import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
import com.yudhi.lock.Lock;
public class lockScreenReeiver extends BroadcastReceiver { public static boolean wasScreenOn = true;
@Override
public void onReceive(Context context, Intent intent) {
//Toast.makeText(context, "" + "enterrrrrr", Toast.LENGTH_SHORT).show();
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { //Toast.makeText(context, "" + "screeen off",
Toast.LENGTH_SHORT).show();
wasScreenOn=false;
Intent intent11 = new Intent(context,Lock.class); intent11.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent11);
// do whatever you need to do here //wasScreenOn = false;
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
wasScreenOn=true; // saat layar hidup menggunakan tombol kunci Intent intent11 = new Intent(context,Lock.class); //proses memanggil activity lock.class
intent11.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//context.startActivity(intent11);
//Toast.makeText(context, "" + "start activity", Toast.LENGTH_SHORT).show();
// and do whatever you need to do here // wasScreenOn = true;
}
else if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
/* KeyguardManager.KeyguardLock k1; KeyguardManager km
=(KeyguardManager)context.getSystemService(context.KEYGUARD_SERVICE); k1 = km.newKeyguardLock("IN");
Intent intent11 = new Intent(context, Lock.class);
intent11.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent11);
// Intent intent = new Intent(context, LockPage.class); // context.startActivity(intent);
// Intent serviceLauncher = new Intent(context, UpdateService.class);
// context.startService(serviceLauncher); // Log.v("TEST", "Service loaded at start"); }
}
}
6. DatabaseManager.java
package com.yudhi.lock;
import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log;
public class DatabaseManager {
public static final String KEY_ROWID = "_id"; public static final String KEY_NAME = "nama"; public static final String KEY_SUARA = "pass"; public static final String TAG = "DBAdapter";
private static final String DATABASE_NAME = "DBLock"; private static final String DATABASE_TABLE = "yudhi"; private static final String DATABASE_TABLE2 = "tbYudhi"; private static final int DATABASE_VERSION = 2;
private static final String DATABASE_CREATE =
"create table yudhi (_id integer primary key autoincrement, " + "nama text not null);";
private static final String DATABASE_CREATE_PASS =
"create table tbYudhi (_id integer primary key autoincrement, "
+ "pass text not null);";
private DatabaseHelper DBHelper; private SQLiteDatabase db;
public DatabaseManager(Context ctx) {
this.context = ctx;
DBHelper = new DatabaseHelper(context); }
private static class DatabaseHelper extends SQLiteOpenHelper { DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION); }
@Override
public void onCreate(SQLiteDatabase db) { try {
db.execSQL(DATABASE_CREATE_PASS); db.execSQL(DATABASE_CREATE); } catch (SQLException e) {
e.printStackTrace(); }
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
Log.w(TAG, "Upgrade database dari versi " + oldVersion + " ke " + newVersion + ", yang akan menghapus semua data lama");
db.execSQL("DROP TABLE IF EXISTS superhero"); onCreate(db);
} }
//---membuka
database---public DatabaseManager open() throws SQLException {
db = DBHelper.getWritableDatabase(); return this;
}
void deleteAll() {
db.delete(DATABASE_TABLE, null, null); db.delete(DATABASE_TABLE2, null, null); }
//---menutup database---public void close() {
//---memasukkan satu record ke database---public long insertOne(String name)
{
ContentValues initialValues = new ContentValues(); initialValues.put(KEY_NAME, name);
return db.insert(DATABASE_TABLE, null, initialValues); }
public long insertPass(String s) {
ContentValues initialValues = new ContentValues(); initialValues.put(KEY_SUARA, s);
return db.insert(DATABASE_TABLE2, null, initialValues); }
//---menghapus satu record tertentu---public boolean deleteOne(long rowId) {
return db.delete(DATABASE_TABLE, KEY_ROWID + "=" + rowId, null) > 0; }
//---menampilkan semua record---public Cursor getAllName() {
return db.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_NAME}, null, null, null, null, null);
}
public Cursor getAllSuara() {
return db.query(DATABASE_TABLE2, new String[] {KEY_ROWID, KEY_SUARA}, null, null, null, null, null);
}
//---menampilkan satu record
tertentu---public Cursor getOne(long rowId) throws SQLException {
Cursor mCursor = db.query(true, DATABASE_TABLE, new String[] {KEY_ROWID, KEY_NAME}, KEY_ROWID + "=" + rowId, null, null, null, null, null);
if (mCursor != null) { mCursor.moveToFirst(); }
return mCursor; }
public Cursor getPass(long rowId) throws SQLException {
Cursor mCursor = db.query(true, DATABASE_TABLE2, new String[]
{KEY_ROWID, KEY_SUARA}, KEY_ROWID + "=" + rowId, null, null, null, null, null);
if (mCursor != null) { mCursor.moveToFirst(); }
}
//---update
record---public boolean updateRecord(long rowId, String name) {
ContentValues args = new ContentValues(); args.put(KEY_NAME, name);
return db.update(DATABASE_TABLE, args, KEY_ROWID + "=" + rowId, null) > 0;
}
public boolean updatePass(long rowId, String i) {
ContentValues args = new ContentValues(); args.put(KEY_SUARA, i);
return db.update(DATABASE_TABLE2, args, KEY_ROWID + "=" + rowId, null) > 0;