我正在创建一个示例图库应用程序,我正在尝试将图库项目存储在本地 sqlite
数据库中
Adapter.class 的方法:
public List<String> getImagePath()
{
ArrayList<String> paths = new ArrayList<String>();
String selectQuery = "SELECT * FROM " + Databaseconnect.TABLE_FILE;
SQLiteDatabase db = dbHelper.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst())
{
do {
paths.add(cursor.getString(3).toString());
// Log.d("getPathImage:", cursor.getString(0).toString());
} while (cursor.moveToNext());
}
return paths;
}
比
MuAdapter= new muadapter(Activityname.this);
mudapter.open();
ArrayList<String> list =getImagePath();
但是我有一个错误
ArrayList<String> list =getImagePath();
如何初始化这个方法?请给我一个解决方案。
最佳答案
MuAdapter= new muadapter(Activityname.this);
// this line is broke. Use something like "MuAdapter muAdapter = new ..."
mudapter.open();
// then this line can work
ArrayList<String> list =getImagePath();
// not sure about this, but don't you need an objectrefernece here, that you call getImagePath() on?!
关于java - 如何使用 Arraylist 将 Sqlite Adapter 类访问到 MainActivity?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33409025/