无法解析 Android Studio 中的符号 getReadableDatabse
Cannot resolve symbol getReadableDatabse in Android Studio
我似乎无法完成这项工作。我正在 android studio 复制一个关于 SQLite 数据库的 youtube 视频教程,我遇到了这个错误。有人可以帮忙吗?谢谢!
public class DataListActivity extends ActionBarActivity {
ListView listView;
SQLiteDatabase sqLiteDatabase;
UserDBHelper userDBHelper;
Cursor cursor;
ListDataAdapter listDataAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.data_list_layout);
listView = (ListView) findViewById(R.id.list_view);
listDataAdapter = new ListDataAdapter(getApplication(), R.layout.row_layout);
listView.setAdapter(listDataAdapter);
userDBHelper = new UserDBHelper(getApplicationContext());
sqLiteDatabase = new userDBHelper.getReadableDatabase();
cursor = userDBHelper.getInformations(sqLiteDatabase);
if (cursor.moveToFirst()) {
do {
String Fname, Lname, Email, Password, Contact, Address;
Fname = cursor.getString(0);
Lname = cursor.getString(1);
Email = cursor.getString(2);
Password = cursor.getString(3);
Contact = cursor.getString(4);
Address = cursor.getString(5);
DataProvider dataProvider = new DataProvider(Fname, Lname, Email, Password, Contact, Address);
listDataAdapter.add(dataProvider);
} while (cursor.moveToNext());
}
}
}
您错位了new
:
sqLiteDatabase = new userDBHelper.getReadableDatabase();
删除它 - 您想要在 userDBHelper
对象上调用 getReadableDatabase()
方法,而不是创建 userDBHelper.getReadableDatabase
class 不存在的新实例。
我似乎无法完成这项工作。我正在 android studio 复制一个关于 SQLite 数据库的 youtube 视频教程,我遇到了这个错误。有人可以帮忙吗?谢谢!
public class DataListActivity extends ActionBarActivity {
ListView listView;
SQLiteDatabase sqLiteDatabase;
UserDBHelper userDBHelper;
Cursor cursor;
ListDataAdapter listDataAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.data_list_layout);
listView = (ListView) findViewById(R.id.list_view);
listDataAdapter = new ListDataAdapter(getApplication(), R.layout.row_layout);
listView.setAdapter(listDataAdapter);
userDBHelper = new UserDBHelper(getApplicationContext());
sqLiteDatabase = new userDBHelper.getReadableDatabase();
cursor = userDBHelper.getInformations(sqLiteDatabase);
if (cursor.moveToFirst()) {
do {
String Fname, Lname, Email, Password, Contact, Address;
Fname = cursor.getString(0);
Lname = cursor.getString(1);
Email = cursor.getString(2);
Password = cursor.getString(3);
Contact = cursor.getString(4);
Address = cursor.getString(5);
DataProvider dataProvider = new DataProvider(Fname, Lname, Email, Password, Contact, Address);
listDataAdapter.add(dataProvider);
} while (cursor.moveToNext());
}
}
}
您错位了new
:
sqLiteDatabase = new userDBHelper.getReadableDatabase();
删除它 - 您想要在 userDBHelper
对象上调用 getReadableDatabase()
方法,而不是创建 userDBHelper.getReadableDatabase
class 不存在的新实例。