android中使用sqlite动态创建表

发布于 2024-11-01 08:48:00 字数 214 浏览 1 评论 0原文

所以我创建和操作数据库的基础知识有点混乱。我的目标是,每当应用程序启动时,用户都可以指定一个表名称,然后收集的任何数据都会放入该表中。

但是,我对如何做到这一点感到困惑。我是否只需将用户输入的变量的值作为我的 contentprovider 类中的表名传递并执行 sqlite 语句来创建它?

我已经阅读/阅读了文档,所以如果有人有任何见解或清晰度,甚至更好的代码片段,那就太好了。

So my fundamentals of creating and manipulating databases are a bit messed up. My aim here is that whenever the app is launched, the user is allowed to specify a table name, and whatever data is then collected is put into that table.

However, I'm confused as to how to do this. Do I simply pass the value of a user entered variable as the table name in my contentprovider class and execute sqlite statements to create it?

I've read/reading the documentation already, so if anyone has any insight or clarity, or even better, code snippets, it would be great.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

波浪屿的海角声 2024-11-08 08:48:00

为什么不简单地使用一个表,并创建一个代表当前应用程序会话的值,然后将该值插入到每一行中。这将使您的代码更简单,并且仍然允许您分离/过滤掉特定应用程序会话中的值。如果您想让用户能够输入值(因为您让他们能够选择表名称),您只需检查该值是否已被使用,就像您必须这样做一样查看表名是否已被使用。

Why not simply use one table, and create a value that stands for the current app-session, and insert that value with each row. This would make your code simpler, and would still allow you to segregate/filter out the values from a particular app-session. If you want to give the user the ability to enter the value (as you are giving them the ability to choose the table name) you'd just want to check to see if that value had already been used, just as you would have to see if the table-name had already been used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文