gpt4 book ai didi

android - 在 android 中存储 EditText 值

转载 作者:搜寻专家 更新时间:2023-10-30 23:12:04 24 4
gpt4 key购买 nike

我开发了一个 android 应用程序...其中...用户姓名姓氏出生日期手机号码、电子邮件 ID 一切都被收集...我想要存储这些详细信息......当用户想要这些数据时......有一个按钮称为召回......当用户按下召回按钮时..可以显示存储此数据的位置..他可以选择他的名字来自这些名字......任何人都知道如何保存这些数据......我正在提供代码......这里......任何人......帮助......代码正在运行......没问题在里面……

public void onDateChanged(DatePicker  arg0, int arg1, int arg2, int arg3) 
{

String date=Integer.toString(arg3);
String month=Integer.toString(arg2);
String year=Integer.toString(arg1);

tv1.setText(date+ month+1 +year);
tv2.setText(month+1 + year);
tv3.setText(year);
tv4.setText(month+1);
tv5.setText(date);
tv6.setText(date + year);

}

});}

public void sum(View v)
{
long sum1=0;
long sum2=0;
long sum3=0;
long sum4=0;
long sum5=0;
long sum6=0;
long sum7=0;
long sum8=0;
long sum=0;
long sum11=0;
long sum12=0;
long sum13=0;
long sum14=0;

EditText et1 = (EditText) findViewById (R.id.editText1);
EditText et2 = (EditText) findViewById (R.id.editText2);
EditText et3 = (EditText) findViewById (R.id.editText3);
EditText et4 = (EditText) findViewById (R.id.editText4);

final DatePicker date = (DatePicker) findViewById (R.id.datePicker1);
final TextView tv1 = (TextView) findViewById (R.id.textView88);
final TextView tv2 = (TextView) findViewById (R.id.textView89);
final TextView tv3 = (TextView) findViewById (R.id.textView90);
final TextView tv4 = (TextView) findViewById (R.id.textView91);
final TextView tv5 = (TextView) findViewById (R.id.textView92);
final TextView tv6 = (TextView) findViewById (R.id.textView93);
final TextView tv7 = (TextView) findViewById (R.id.textView94);

sum1=getSum(et1.getText().toString() + et2.getText().toString() + et3.getText().toString() + et4.getText().toString());
sum2=getSum1(et1.getText().toString() + et2.getText().toString() + et3.getText().toString() + et4.getText().toString());
sum3=getSum2(tv1.getText().toString());
/*sum4=getSum3(tv2.getText().toString());*/
sum5=getSum4(tv3.getText().toString());
sum6=getSum5(tv4.getText().toString());
sum8=getSum7(tv5.getText().toString());

String yearf = tv3.getText().toString();
int yearb = Integer.valueOf(yearf);

int val = 2013 - yearb;
long val1 = sum3;
/*int val2 = Integer.valueOf(val1);*/
long val3 = 36 - val1;
int val4 = 9;
long val5 = val3 + val4;
long val6 = val5 + val4;
long val7 = val6 + 50;

sum = getSum3(tv2.getText().toString()) + getSum8(tv6.getText().toString());

if (val <= val3)
{
sum4=getSum3(tv2.getText().toString());
}

else if ((val <= val5) && (val > val3))
{
sum4=getSum8(tv6.getText().toString());
}

else if ((val<=val6) && (val > val5) && (val > val3))
{
/*sum = getSum3(tv2.getText().toString()) + getSum8(tv6.getText().toString());*/
sum4=getSum9(Integer.toString((int) sum));
}
else
{
sum4=getSum9(Integer.toString((int) sum));
}

if (val <= val3)
{

if (sum5>sum6)
{
sum7 = (sum5 - sum6);
}
else
{
sum7 = (sum6 - sum5);
}

}

else if ((val <= val5) && (val > val3))
{
if(sum5>sum8)
{
sum7=(sum5 - sum8);
}
else
{
sum7 = (sum8 - sum5);
}
}


else if ((val<=val6) && (val > val5) && (val > val3))
{
sum11 = (sum5 - sum8);
sum12 = (sum8 - sum5);
sum13 = (sum6 - sum5);
sum14 = (sum5 - sum6);

if ((sum11 > sum12) && (sum13 > sum14))
{
if (sum11 > sum13)
{
sum7 = sum11 - sum13;
}
else
{
sum7 = sum13 - sum11;
}
}
else if ((sum12 > sum11) && (sum13 > sum14))
{
if (sum12 > sum13)
{
sum7 = sum12 - sum13;
}
else
{
sum7 = sum13 - sum12;
}
}
else if ((sum11 > sum12) && (sum14 > sum13))
{
if (sum11 > sum14)
{
sum7 = sum11 - sum14;
}
else
{
sum7 = sum14 - sum11;
}
}
else if ((sum12 > sum11) && (sum14 > sum13))
{
if (sum12 > sum14)
{
sum7 = sum12 - sum14;
}
else
{
sum7 = sum14 - sum12;
}
}

}
else
{
sum11 = (sum5 - sum8);
sum12 = (sum8 - sum5);
sum13 = (sum6 - sum5);
sum14 = (sum5 - sum6);

if ((sum11 > sum12) && (sum13 > sum14))
{
if (sum11 > sum13)
{
sum7 = sum11 - sum13;
}
else
{
sum7 = sum13 - sum11;
}
}
else if ((sum12 > sum11) && (sum13 > sum14))
{
if (sum12 > sum13)
{
sum7 = sum12 - sum13;
}
else
{
sum7 = sum13 - sum12;
}
}
else if ((sum11 > sum12) && (sum14 > sum13))
{
if (sum11 > sum14)
{
sum7 = sum11 - sum14;
}
else
{
sum7 = sum14 - sum11;
}
}
else if ((sum12 > sum11) && (sum14 > sum13))
{
if (sum12 > sum14)
{
sum7 = sum12 - sum14;
}
else
{
sum7 = sum14 - sum12;
}
}

}


String edtxt1 = et1.getText().toString();
String edtxt4 = et4.getText().toString();

if(edtxt1.equals(""))
{
Toast.makeText(getApplicationContext(),"First Name should not be left blank, Please enter your First Name ", Toast.LENGTH_LONG).show();
}

else if(edtxt4.equals(""))
{
Toast.makeText(getApplicationContext(),"Last Name should not be left blank, Please enter your Last Name ", Toast.LENGTH_LONG).show();
}

else{

Intent i = new Intent(this, result.class);
i.putExtra("name", sum1 + "");
i.putExtra("name1", sum2 + "");
i.putExtra("name2", sum3 + "");
i.putExtra("name3", sum4 + "");
i.putExtra("name4", sum7 + "");

startActivity(i);

}

最佳答案

你应该看看Storage Options .但是如果这不是很多用户可以使用 SharedPreferences .该链接有一个很好的开始使用它们的例子。

如果您要让多个用户拥有那么多不同的数据,那么您可能需要考虑使用 SQLite DB .如果您不习惯使用 SQLite Db,那么 this tutorial可能是帮助您入门的好方法。

您也可以使用我提供的链接中的其他存储选项,但数据库可能是为不同用户存储大量不同信息的最佳选择。

关于android - 在 android 中存储 EditText 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18539188/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com