我正在尝试打开并写入Android中的Sqlite数据库。根据日志输出,它没有打开。我知道我的语法不是很好,我应该从Party对象中保存而不是直接从片段接口保存,但我的重点是在过程中。任何帮助都会非常有帮助!
public class TransactionFragment extends Fragment
{
TextView tv1;
public TransactionFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
tv1=(TextView) container.findViewById(R.id.textView1);
SQLiteDatabase db=openOrCreateDatabase("ExpensesDB",null);
// Toast.makeText(AddTransactionActivity.this,s3.getSelectedItem().toString(),Toast.LENGTH_LONG).show();
String q2="select * from Expense";
Cursor e=db.rawQuery(q2,null);
String data ="EMP Names:\n------------\n";
while (e.moveToNext())
{
data=data+e.getString(1)+"\n";
}
tv1.setText(data);
db.close();
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_transaction, container, false);
}
下面是输出文件 Log output
答案 0 :(得分:0)
我相信您应该将上下文发送给构建器......