in the program I have 3 fields to enter when I enter data and pressed for starting the button below creates three dynamic input fields, the program calculates the average score of only 3 top fields. I want that when the user changed any data in dynamically created fields it counted the data from these fields, regardless of their number
package com.example.averegemark;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TableRow.LayoutParams;
import android.widget.TextView;
import android.widget.Toast;
public class Table extends Activity {
LinearLayout LL;
EditText et1,et2,et3;
double coef=0,points=0,sum=0,coefsum=0;
TextView total;
Button bNext;
String name="",mark="",coeff="";
int i=0;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.table);
bNext = (Button) findViewById(R.id.bNext);
et1 = (EditText) findViewById(R.id.et1);
et2 = (EditText) findViewById(R.id.et2);
et3 = (EditText) findViewById(R.id.et3);
total = (TextView) findViewById(R.id.tvTotal);
total.setText("GPA:");
LL = (LinearLayout) findViewById(R.id.LL);
bNext.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
name = et1.getText().toString();
mark = et2.getText().toString();
coeff = et3.getText().toString();
if(mark.length()==0 || coeff.length()==0)
Toast.makeText(getApplicationContext(), "Enter mark `and coefficient", Toast.LENGTH_LONG).show();
else
NewView(name,mark,coeff);
}
});
}
private void NewView(String name, String mark, String coeff) {
// TODO Auto-generated method stub
EditText info1 = new EditText(this);
EditText info2 = new EditText(this);
EditText info3 = new EditText(this);
info1.setId(i);i++;
info1.setId(i);i++;
info1.setId(i);i++;
info1.setText(""+name);
info2.setText(""+mark);
info3.setText(""+coeff);
TableLayout table = (TableLayout) findViewById(R.id.tbl);
table.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
TableRow row = new TableRow(this);
row.setLayoutParams(new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
row.addView(info1);
row.addView(info2);
row.addView(info3);
table.addView(row);
String rez="";
rez= info2.getText().toString();
points = Double.parseDouble(rez);
rez= info3.getText().toString();
coef = Double.parseDouble(rez);
sum +=coef*points;
coefsum+=coef;
sum/=coefsum;
total.setText("GPA : "+sum+"\nCoefficient sum. "+coefsum);
et3.setText("");
et2.setText("");
et1.setText("");
et1.requestFocus();
}
}
so when I will change any data in row , i want to recalculate this, but here it use only top EditText not dynamically created :
String rez="";
rez= info2.getText().toString();
points = Double.parseDouble(rez);
rez= info3.getText().toString();
coef = Double.parseDouble(rez);
sum +=coef*points;
coefsum+=coef;
sum/=coefsum;
total.setText("GPA : "+sum+"\nCoefficient sum. "+coefsum);
When you press the button, you get the information from the original edittexts. You have to find the last row in the table and get the edittexts from there.
CharSequence data = ((TextView) v).getText();
String result = data.toString();
Related
I have recently started working in android studio, and I am trying to make the UI of an app before I add any SQL, because I don't want to learn a language for a program that won't work, but any way, I tried to use a TableLayout with text boxes, and take user input and insert it into that table. It does not work. I keep getting an error shown in the picture.[error shown][1]
package com.example.tj_n126.firstappattempt;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.
public class MainActivity extends AppCompatActivity {
private TextView mTextMessage;
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
#Override
public boolean onNavigationItemSelected(#NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.navigation_home:
mTextMessage.setText(R.string.title_home);
return true;
case R.id.navigation_dashboard:
mTextMessage.setText(R.string.title_dashboard);
return true;
case R.id.navigation_notifications:
mTextMessage.setText(R.string.title_notifications);
return true;
}
return false;
}
};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView lastNameDisplay = findViewById(R.id.lNameTxt);
TextView firstNameDisplay = findViewById(R.id.nameTxt);
TextView phoneNumDisplay = findViewById(R.id.phoneTxt);
TextView emailDisplay = findViewById(R.id.emailTxt);
TextView accBalDisplay = findViewById(R.id.accBal);
firstNameDisplay.setText("First");
lastNameDisplay.setText("Last");
phoneNumDisplay.setText("Phone");
emailDisplay.setText("Email");
accBalDisplay.setText("Balance");
final Button newUserButton = findViewById(R.id.newUserButton);
newUserButton.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View view){
//this is for inputs on a separate page
setContentView(R.layout.layout2);
final TextView lastName = findViewById(R.id.lastName);
final TextView firstName = findViewById(R.id.firstName);
final TextView phoneNumber = findViewById(R.id.phoneNumber);
final TextView email = findViewById(R.id.emailAddress);
final TextView accountBalance = findViewById(R.id.accountAmount);
Button submitBtn = findViewById(R.id.submitBtn);
submitBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
setContentView(R.layout.activity_main);
//These are the textboxes in the table
TextView fName = findViewById(R.id.fName);
TextView lName = findViewById(R.id.lName);
TextView phone = findViewById(R.id.phone);
TextView emailAdd = findViewById(R.id.email);
TextView balance = findViewById(R.id.Balance);
fName.setText(firstName + "");
lName.setText(lastName + "");
phone.setText(phoneNumber + "");
emailAdd.setText(email + "");
balance.setText(accountBalance + "");
}
});
}
});
mTextMessage = (TextView) findViewById(R.id.message);
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
}
}
[1]: https://i.stack.imgur.com/8CfWD.png
In this line of your code:
fName.setText(firstName + "");
the variable firstName is actually a TextView, so the compiler will implicitly call firstName.toString() which will give you the string that you see (it will NOT give you the text in the TextView). The line should probably be:
fName.setText(firstName.getText());
Ditto for the other places where you use the TextView + "" pattern (which I would discourage from using for any reason).
I am trying to get the value of inputEditText and multiply it by the value of convertNum.
The error I'm getting is: Operator '*' cannot be applied to 'android.widget.EditText','double'
I believe I need to convert the value of inputEditText into a number, but I'm not sure. Any help would be appreciated. Here is my code:
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Declare variables
final Button calculateButton = (Button) findViewById(R.id.button);
final TextView resultTextView = (TextView) findViewById(R.id.textView2);
final TextView resultnumTextView = (TextView) findViewById(R.id.textView3);
final EditText inputEditText = (EditText) findViewById(R.id.editText);
final double convertNum = 0.125;
// Set resultTextView to be invisible on app start
resultTextView.setVisibility(View.INVISIBLE);
// When calculate button is pressed: Set resultTextView to visible and show result
calculateButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
resultTextView.setVisibility(View.VISIBLE);
resultnumTextView.setText(inputEditText * convertNum);
}
});
}
You get the error as you are trying to multiply EditText (which is a View instance) and double (which is a number).
Easiest fix is to replace
resultnumTextView.setText(inputEditText * convertNum);
with
resultnumTextView.setText(String.valueOf(
Float.valueOf(inputEditText.getText().toString()) * convertNum
));
Instead of this:
resultnumTextView.setText(inputEditText * convertNum);
Do this:
resultnumTextView.setText(Double.parseDouble(inputEditText.getText().toString()) * convertNum);
inputEditText is an EditText, a widget to write text. You need to extract the typed text and convert into a float.
inputEditText.getText().toString()
Will give you a String with the typed text. Then use the wrapper class Float to convert into a number
String s = inputEditText.getText().toString();
Float f= Float.parseFloat(s);
As you can see here
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Declare variables
final Button calculateButton = (Button) findViewById(R.id.button);
final TextView resultTextView = (TextView) findViewById(R.id.textView2);
final TextView resultnumTextView = (TextView) findViewById(R.id.textView3);
final EditText inputEditText = (EditText) findViewById(R.id.editText);
final double convertNum = 0.125;
// Set resultTextView to be invisible on app start
resultTextView.setVisibility(View.INVISIBLE);
// When calculate button is pressed: Set resultTextView to visible and show result
calculateButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String valueFromInput = inputEditText.getText().toString();
try{
double valueToDouble = Double.parseDouble(valueFromInput);
double result = convertNum * valueToDouble;
resultnumTextView.setText(result+"");
resultTextView.setVisibility(View.VISIBLE);
}catch(Exception e){
// print the exception.
}
}
});
}
I know it's a pretty amateur question , but i am really getting frustrated:
I am not getting an error but its just not working.(Ignore the bundle part)package com.example.project1;import android.app.Activity;
here's the java file
package com.example.project1;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Tictactoe2 extends Activity implements OnClickListener{
EditText et1 , et2;
String str1 , str2;
Button b1;
TextView tv2;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.ttt);
et1 = (EditText) findViewById (R.id.et1);
et2 = (EditText) findViewById (R.id.et2);
tv2 = (TextView) findViewById (R.id.tv2);
str1 = et1.getText().toString();
str2 = et2.getText().toString();
b1 = (Button) findViewById (R.id.b1);
b1.setOnClickListener(this);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId())
{
case R.id.b1:
tv2.setText(str1);
/*Bundle bun = new Bundle();
bun.putString("key", str1);
bun.putString("key1", str2);;
Intent intent = new Intent(tictactoe2.this , tictactoe.class);
intent.putExtras(bun);
startActivity(intent);*/
break;
}}
}
I guess you got NPE. You need to remove this lines
str1 = et1.getText().toString();
str2 = et2.getText().toString();
It's because you're trying to getText() from EditText and there is no Text in it. So i would suggest you move this lines under some Listener events where you get values after you set value in your EditText.
You implement like
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId())
{
case R.id.b1:
str1 = et1.getText().toString();
str2 = et2.getText().toString();
tv2.setText(str1);
}}
package com.example.project1;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Tictactoe2 extends Activity implements OnClickListener{
EditText et1 , et2;
String str1 , str2;
Button b1;
TextView tv2;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.ttt);
et1 = (EditText) findViewById (R.id.et1);
et2 = (EditText) findViewById (R.id.et2);
tv2 = (TextView) findViewById (R.id.tv2);
b1 = (Button) findViewById (R.id.b1);
b1.setOnClickListener(this);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId())
{
case R.id.b1:
str1 = et1.getText().toString();
str2 = et2.getText().toString();
tv2.setText(str1);
/*Bundle bun = new Bundle();
bun.putString("key", str1);
bun.putString("key1", str2);;
Intent intent = new Intent(tictactoe2.this , tictactoe.class);
intent.putExtras(bun);
startActivity(intent);*/
break;
}}
}
you should place your "str1" String and textview and edittext code in your onClick.
like this:
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId())
{
case R.id.b1:
et1 = (EditText) findViewById (R.id.et1);
tv2 = (TextView) findViewById (R.id.tv2);
str1 = et1.getText().toString();
tv2.setText(str1);
/*Bundle bun = new Bundle();
bun.putString("key", str1);
bun.putString("key1", str2);;
Intent intent = new Intent(tictactoe2.this , tictactoe.class);
intent.putExtras(bun);
startActivity(intent);*/
break;
}}
I am trying to deveolp an Android application. I am learning Android so there I go.
My aplication is similar to this one: http://www.tutorialspoint.com/android/android_camera.htm ;
Except I have two activities.. One is called Report.java and the other one is called Form.java.
In Report.java, I have a button, when I click the button, I want to open the camera and take a picture. After I took the picture, I want to start the second activity (Form.java) and my image to be saved in an ImageView.
How can I do that? Thank you in advance.
Report.java
package com.example.harta;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class Report extends Activity implements View.OnClickListener{
ImageView iv;
Button report;
final static int cameraData = 0;
Bitmap bmp;
Intent i;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.report);
initialize();
report.setOnClickListener(this);
}
private void initialize() {
// TODO Auto-generated method stub
report = (Button) findViewById(R.id.bReport);
}
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.bReport:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, cameraData);
break;
}
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK){
Bundle extras = data.getExtras();
bmp = (Bitmap) extras.get("data");
Intent i = new Intent(Report.this, Formular.class);
startActivity(i);
}
}
}
Form.java
package com.example.harta;
import java.io.IOException;
import java.io.InputStream;
import android.app.Activity;
import android.app.WallpaperManager;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
public class Formular extends Activity{
Button button;
ImageView iv;
int cameraResults;
final static int cameraData = 0;
Bitmap bmp;
TextView tvAdress, tvAmpers, tvCommunication, tvCoordinates;
TextView tvName, tvInformations, tvDataIntro, tvPhone, tvLatitude;
TextView tvLongitude, tvInstalledPower, tvContor, tvNetwork;
EditText etAdress, etAmpers, etCommunication, etCoordinates;
EditText etName, etInformations, etDataIntro, etPhone, etLatitude;
EditText etLongitude, etInstalledPower, etContor, etNetwork;
Spinner spinNetwork;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.formular);
initialize();
}
private void initialize() {
// TODO Auto-generated method stub
tvAdress = (TextView) findViewById(R.id.tvAdresa);
tvAmpers = (TextView) findViewById(R.id.tvAmperaj);
tvCommunication = (TextView) findViewById(R.id.tvComunicatie);
tvCoordinates = (TextView) findViewById(R.id.tvCoord);
tvName = (TextView) findViewById(R.id.tvDenumire);
tvInformations = (TextView) findViewById(R.id.tvInfo);
tvDataIntro = (TextView) findViewById(R.id.tvIntroducereDate);
tvPhone = (TextView) findViewById(R.id.tvIPtelefon);
tvLatitude = (TextView) findViewById(R.id.tvLat);
tvLongitude = (TextView) findViewById(R.id.tvLong);
tvInstalledPower = (TextView) findViewById(R.id.tvPutereInstalata);
tvContor = (TextView) findViewById(R.id.tvSerieContor);
tvNetwork = (TextView) findViewById(R.id.tvTipulRetelei);
etAdress = (EditText) findViewById(R.id.etAdresa);
etAmpers = (EditText) findViewById(R.id.etAmperaj);
etCommunication = (EditText) findViewById(R.id.etComunicatie);
etName = (EditText) findViewById(R.id.etDenumire);
etPhone = (EditText) findViewById(R.id.etIPtelefon);
etInstalledPower = (EditText) findViewById(R.id.etPutereInstalata);
etContor = (EditText) findViewById(R.id.etSerieContor);
spinNetwork = (Spinner) findViewById(R.id.spinTipulRetelei);
button = (Button) findViewById(R.id.bTrimitere);
iv = (ImageView) findViewById(R.id.ivPic);
}
public void onClick(View v) {
// TODO Auto-generated method stub
}
}
i have a registration app in the making where the user registers the data and on the other end the data can be shown and viewed and manipulated , i am using shared preferences method as shown below to write and access data (you can see them in DataEntry.java & DataManipulation.java shown below) but i want to use content provider method to manipulate data like quering or inserting or deleting....is there a way to do this and if yes can you please tell me how?
thank you
here are the codes below
the User end DataEntry.java:
package com.hossa.datamanipulation;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
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;
import android.widget.TextView;
import android.widget.Toast;
public class DataEntry extends Activity {
/*
* here is the part the user will submit several data for several people
*/
Button Submit, BroadcastButton;
TextView User, Email, Mobile;
EditText UserEdit, EmailEdit, MobileEdit;
String UserValue, EmailValue, MobileValue;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dataentry);
Submit = (Button) findViewById(R.id.DataSubmit);
BroadcastButton = (Button) findViewById(R.id.Broadcast);
User = (TextView) findViewById(R.id.TVuser);
Email = (TextView) findViewById(R.id.TVemail);
Mobile = (TextView) findViewById(R.id.TVmobile);
UserEdit = (EditText) findViewById(R.id.Edituser);
EmailEdit = (EditText) findViewById(R.id.Editemail);
MobileEdit = (EditText) findViewById(R.id.Editmobile);
Submit.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
// saving the data of the user//
SharedPreferences sp = getSharedPreferences("userdata",
MODE_PRIVATE);// name of the file and it's mode//
SharedPreferences.Editor edit = sp.edit();// to be able to edit
// the file//
edit.putString("Username", UserEdit.getText().toString());// get
// the
// input
// username//
edit.putString("Email", EmailEdit.getText().toString());// get
// the
// input
// Email//
edit.putString("Mobile", MobileEdit.getText().toString());// get
// the
// input
// Mobile//
edit.commit();
Toast.makeText(getApplicationContext(),
"Data is Saved Successfully", Toast.LENGTH_SHORT)
.show();
}
});
BroadcastButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent e = new Intent();
e.setAction("com.hossa.data" + "manipulation.custombroadcast");
sendBroadcast(e);
}
});
}
#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;
}
}
and the other end DataManipulaton.java:
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
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;
import android.widget.TextView;
import android.widget.Toast;
public class DataManipulation extends Activity {
Button ImportButton, ViewButton, RetrieveButton;
EditText UserShow;
TextView EmailDisplay, UserDisplay, MobileDisplay, EmailTV, UserTV,
MobileTV;
public static final String defaultvalue = "N/A";
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.datamanipulation);
ContentResolver ct = getContentResolver();
String Path = "data/data/com.hossa.datamanipulation/files/userdata";
Uri uri = Uri.parse("content://" + Path);
ImportButton = (Button) findViewById(R.id.ImportButton);
ViewButton = (Button) findViewById(R.id.ViewButton);
RetrieveButton = (Button) findViewById(R.id.RetrieveButton);
EmailDisplay = (TextView) findViewById(R.id.EmailDisplay);
MobileDisplay = (TextView) findViewById(R.id.MobileDisplay);
UserDisplay = (TextView) findViewById(R.id.UsernameDisplay);
EmailTV = (TextView) findViewById(R.id.EmailTV2);
UserTV = (TextView) findViewById(R.id.UserTV2);
MobileTV = (TextView) findViewById(R.id.MobileTV2);
final String U1[] = new String[10];
final String E1[] = new String[10];
final String M1[] = new String[10];
final String[][] alldata = new String[][] { U1, M1, E1 };
RetrieveButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
int i = 0;
SharedPreferences spdata = getSharedPreferences("userdata",
Context.MODE_PRIVATE);
while (spdata.getString("Username", defaultvalue) != null) {
String tempuser = spdata
.getString("Username", defaultvalue);
U1[i] = tempuser;
i++;
}
i = 0;
while (spdata.getString("Email", defaultvalue) != null) {
String tempemail = spdata.getString("Email", defaultvalue);
E1[i] = tempemail;
i++;
}
i = 0;
while (spdata.getString("Mobile", defaultvalue) != null) {
String tempmobile = spdata
.getString("Mobile", defaultvalue);
M1[i] = tempmobile;
i++;
}
i = 0;
}
});
ImportButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
getApplicationContext();
// TODO Auto-generated method stub
SharedPreferences sp = getSharedPreferences("userdata",
Context.MODE_PRIVATE);
String Username = sp.getString("Username", defaultvalue);
String Email = sp.getString("Email", defaultvalue);
String Mobile = sp.getString("Mobile", defaultvalue);
// what if there is no data from the user??//
if (Username.equals(defaultvalue) || Email.equals(defaultvalue)
|| Mobile.equals(defaultvalue)) {
Toast.makeText(getApplicationContext(),
"no data has been entered", Toast.LENGTH_SHORT)
.show();
} else {
UserTV.setText(Username);
EmailTV.setText(Email);
MobileTV.setText(Mobile);
}
}
});
//THE BELOW IS THE SECTION I NEED HELP WITH...THE ABOVE IS SIMPLY SOME TRIALS AND TESTS//
Cursor c = ct.query(uri, U1, null, null, null);
// c=ct.delete(uri, where, selectionArgs);
// c=ct.update(uri, values, where, selectionArgs);
}
#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;
}
}
PLEASE NOTE THAT BOTH CLASSES ARE IN THE SAME PACKAGE SO IT IS THE SAME APP NOT 2 DIFFERENT APPS