Android:E/SQLiteLog:(1)没有这样的列:******在“从视图中选择*信息广告,其中******=?”
当我运行我的应用程序时,它崩溃了Android:E/SQLiteLog:(1)没有这样的列:******在“从视图中选择*信息广告,其中******=?”,android,database,sqlite,android-sqlite,Android,Database,Sqlite,Android Sqlite,当我运行我的应用程序时,它崩溃了 E/AndroidRuntime: FATAL EXCEPTION: main Process: com.tooozy.accountbook, PID: 7669 android.database.sqlite.SQLiteException: no such column: a.username (code 1 SQLITE_ERROR): , while compiling: select * from view_info_ad where
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.tooozy.accountbook, PID: 7669
android.database.sqlite.SQLiteException: no such column: a.username (code 1 SQLITE_ERROR): , while compiling: select * from view_info_ad where a.username=?
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1045)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:652)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
.....
at com.tooozy.accountbook.DB.AccountDetailDao.marefuck(AccountDetailDao.java:112)
at com.tooozy.accountbook.Fragment.Fragment_Account_Detail.onCreateView(Fragment_Account_Detail.java:41)
这是我的数据库代码
private static final String mInformationSqlStr =" create table " + InformationDao.TABLE_NAME + " ( "+
InformationDao.KEY_ID + " integer primary key autoincrement, " +
InformationDao.KEY_USERNAME + " text not null, " +
InformationDao.KEY_PSW + " text not null , " +
InformationDao.KEY_EMAIL + " text ); " ;
private static final String mAccountDetailSqlStr =" create table " + AccountDetailDao.TABLE_NAME + " ( "+
AccountDetailDao.KEY_ID + " integer primary key autoincrement, " +
AccountDetailDao.KEY_ACCOUNTTYPE + " text not null, " +
AccountDetailDao.KEY_ACCOUNTNAME + " text not null, " +
AccountDetailDao.KEY_AMOUNT + " text not null, " +
AccountDetailDao.KEY_DATE + " text not null, " +
AccountDetailDao.KEY_COMMENT + " text, " +
AccountDetailDao.KEY_USERNAME + "text );" ;
private static final String THEVIEW = " create view [view_info_ad] " +
" AS " +
" SELECT " +
"[a].[accounttype]," +
"[a].[accountname]," +
"[a].[amount]," +
"[a].[date]," +
"[a].[username]," +
"[b].*" +
" FROM [detailmessage] [a]" +
" LEFT JOIN [userinfo] [b] ON [a].[username] = [b].[username]; ";
我的片段代码
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.account_detail_fragment,container,false);
listview = view.findViewById(R.id.expandablelistview);
/*(Fragment_Account_Detail.java:41)*/AllData = MyApplication.mdbmaster.mAccountDetailDao.marefuck();
Child = new HashMap<String, ArrayList<AccountDetailBean>>();
Child.put(Group.get(0),AllData.get(0));
Child.put(Group.get(1),AllData.get(1));
Child.put(Group.get(2),AllData.get(2));
Child.put(Group.get(3),AllData.get(3));
Child.put(Group.get(4),AllData.get(4));
Child.put(Group.get(5),AllData.get(5));
Child.put(Group.get(6),AllData.get(6));
Child.put(Group.get(7),AllData.get(7));
adapter_accountItem = new Adapter_AccountItem(Group, Child,this.getContext());
listview.setAdapter(adapter_accountItem);
registerForContextMenu(listview);
return view;
}
还有我的sql代码
ublic ArrayList<ArrayList<AccountDetailBean>> marefuck(){
ArrayList<ArrayList<AccountDetailBean>> result = new ArrayList<ArrayList<AccountDetailBean>>();
ArrayList<AccountDetailBean> list0 = new ArrayList<>();
ArrayList<AccountDetailBean> list1 = new ArrayList<>();
ArrayList<AccountDetailBean> list2 = new ArrayList<>();
ArrayList<AccountDetailBean> list3 = new ArrayList<>();
ArrayList<AccountDetailBean> list4 = new ArrayList<>();
ArrayList<AccountDetailBean> list5 = new ArrayList<>();
ArrayList<AccountDetailBean> list6 = new ArrayList<>();
ArrayList<AccountDetailBean> list7 = new ArrayList<>();
String sql = "select * from view_info_ad where a.username=?";
/*(AccountDetailDao.java:112)*/Cursor cursor = mDatabase.rawQuery(sql,new String[]{MainActivity.INFORMATIONBEAN.getUsername()});
while (cursor.moveToNext()){
String accounttype = cursor.getString(cursor.getColumnIndex("accounttype"));
String accountname = cursor.getString(cursor.getColumnIndex("accountname"));
String amount = cursor.getString(cursor.getColumnIndex("amount"));
String date = cursor.getString(cursor.getColumnIndex("date"));
AccountDetailBean aaa = new AccountDetailBean().AccountDetailBrief(accountname,amount,date);
switch (accounttype){
case "0":
list0.add(aaa);
break;
case "1":
list1.add(aaa);
break;
case "2":
list2.add(aaa);
break;
case "3":
list3.add(aaa);
break;
case "4":
list4.add(aaa);
break;
case "5":
list5.add(aaa);
break;
case "6":
list6.add(aaa);
break;
case "7":
list7.add(aaa);
break;
}
}
result.add(list0);result.add(list1);result.add(list2);result.add(list3);
result.add(list4);result.add(list5);result.add(list6);result.add(list7);
return result;
}
我尝试重新安装我的应用程序,重新创建我的虚拟设备,但没有帮助
我想在expandablelistview上显示消息片段中的内容
我使用sqlite数据库来完成注册和登录任务,这可能不是数据库的问题