gpt4 book ai didi

java - 尝试将信息从 Android 应用程序中的 4 个字段传递到 java 中的字符串,以便在保存信息之前测试连接

转载 作者:行者123 更新时间:2023-11-29 23:30:34 24 4
gpt4 key购买 nike

我正在编写一个连接到MySQL服务器的Android应用程序,到目前为止我已经有了它,这样用户就可以输入服务器IP、数据库名称、用户名和密码并将其存储到手机上。我正在尝试根据用户刚刚输入的信息构建一个字符串,以在保存到 .txt 文件之前测试连接。我知道它可能就在我面前,但经过一天之后我被困住了,请帮忙!问题出在“TestButtonListener”

public class AppInfo extends Activity {

public static final String DEBUGTAG = "It's Broke";
public static final String DATABASEPASSWORD = "pinfo.txt";
public static final String SERVERIP = "sinfo.txt";
public static final String DATABASEUSER = "ninfo.txt";
public static final String DATABASE = "dinfo.txt";
public static final String FILESAVED = "filesaved";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_app_info);
addTestButtonListener();


///Test connection
private void addTestButtonListener() {
Button test = (Button) findViewById(R.id.testcon);
test.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
///need information from the R.id.server, R.id.database, R.id.name, R.id.pword
/// and insert it into the string as serverIp, dataBase, name, pword.
///
try {
/// everything I've tried in here spits out the name of the text file,
/// or the memory address, but not the value just typed in.
}

String serverConnect = new String("jdbc:mysql://" + serverIp
+ "/" + dataBase + ", " + name + ", " + pword);

Toast.makeText(AppInfo.this, serverConnect, Toast.LENGTH_LONG)
.show();

}
});
}

最佳答案

别费心了,我想出了如何用 .getText().toString() 修复它,毕竟我发现 Android 不能与 jdbc 连接器一起工作。

关于java - 尝试将信息从 Android 应用程序中的 4 个字段传递到 java 中的字符串,以便在保存信息之前测试连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26610663/

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