java⽆法解析_如何在Java中解决“⽆法解析⽅法”Insertdata“?我试着插⼊数据到SQLite。但是AddActivity.java中有⼀些错误。我的概念是向SQLite插⼊数据。从数据显⽰列表中读取数据后。如何在Java中解决“⽆法解析⽅法”Insertdata'“?
当在数据列表上单击列表时,它将显⽰此列表的详细信息。
以下是错误:
Cannot resolve method 'Insertdata(java.lang.String,java.lang.String,java.lang.String)'
myDBClass.java
ample.puen.projectdemo;
t.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import java.util.ArrayList;
import java.util.HashMap;
public class myDBClass extends SQLiteOpenHelper {
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "mydatabase";
// Table Name
private static final String TABLE_MEMBER = "members";
public myDBClass(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION); // TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
// Create Table Name
" Tel TEXT(100));");
Log.d("CREATE TABLE", "Create Table Successfully.");
}
// Select Data
public String[] SelectData(String strMemberID) {
// TODO Auto-generated method stub
try {
String arrData[] = null;
SQLiteDatabase db;
db = ReadableDatabase(); // Read Data
Cursor cursor = db.query(TABLE_MEMBER, new String[]{"*"}, "MemberID=?",
new String[]{String.valueOf(strMemberID)}, null, null, null, null); if(cursor != null)
{
if (veToFirst()) {
arrData = new ColumnCount()];
/***
* 0 = MemberID
* 1 = Name
* 2 = Tel
*/
arrData[0] = String(0);
arrData[1] = String(1);
arrData[2] = String(2);
}
}
cursor.close();
db.close();
return arrData;
} catch (Exception e) {
return null;
}
}
// Show All Data
public ArrayList> SelectAllData() {
// TODO Auto-generated method stub
try {
ArrayList> MyArrList = new ArrayList<>();
HashMap map;
SQLiteDatabase db;
db = ReadableDatabase(); // Read Data
String strSQL = "SELECT * FROM " + TABLE_MEMBER; Cursor cursor = db.rawQuery(strSQL, null);
if(cursor != null)
{
if (veToFirst()) {
do {
map = new HashMap<>();
map.put("MemberID", String(0));
map.put("Name", String(1));
map.put("Tel", String(2));
MyArrList.add(map);
} while (veToNext());
}
}
cursor.close();
db.close();
return MyArrList;
} catch (Exception e) {
return null;
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub
// Re Create on method onCreate
onCreate(db);
}
}
AddActivity.java
ample.puen.projectdemo;
import android.app.Activity;
import android.app.AlertDialog;
t.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.app.Activity;
import android.app.AlertDialog;
t.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;java类的概念
public class AddActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_add);
// btnSave (Save)
final Button save = (Button) findViewById(R.id.btnSave);
save.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// If Save Complete
if(SaveData())
{
// Open Form Main
Intent newActivity = new Intent(AddActivity.this,MainActivity.class); startActivity(newActivity);
}
}
});
// btnCancel (Cancel)
final Button cancel = (Button) findViewById(R.id.btnCancel);
cancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
/
/ Open Form Main
Intent newActivity = new Intent(AddActivity.this,MainActivity.class); startActivity(newActivity);
}
});
}
public boolean SaveData()
{
// txtMemberID, txtName, txtTel
final EditText tMemberID = (EditText) findViewById(MemberID); final EditText tName = (EditText) findViewById(Name);
final EditText tTel = (EditText) findViewById(Tel);
// Dialog
final AlertDialog.Builder adb = new AlertDialog.Builder(this);

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。