如何保存在一个Android应用程序的信息程度的不确定性? [英] How to save an uncertain amount of information in an android app?

查看:192
本文介绍了如何保存在一个Android应用程序的信息程度的不确定性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我的建筑,对用户输入数据的应用程序,如任务管理器会怎么做。例如,用户会点击一个按钮,名为创建新事件,然后我的应用程序导致他们有一大堆的问题,如屏幕日期?时间?和事件的名字吗?。在这个屏幕的底部是一个完成按钮。而当用户点击这个按钮,我需要的应用程序,以保存由用户输入的所有信息,并将其保存到一个文件具有相同名称的事件。我需要这个文件如果需要和保存,直到用户决定删除的事件能够被访问。所以它几乎就像做一个日历应用程序,允许某人进入一个事件,并保持在日历上该事件。即使应用程序关闭,该事件应该在日历上,当用户再次打开该应用程序。我知道我很可能会使用共享preferences,包裹和文件,但我不知道怎么有我的code使一个唯一的文件名每一个事件是由时间。

So, I am building an app that has the user input data such as a task manager would do. For example, the user will click on a button called "Create new event" and then my app leads them to a screen that has a bunch of questions such as "Date? Time? and name of event?". At the bottom of this screen is a "done" button. And when the user clicks this button, I need the app to save all the information that was entered by the user, and save it into a file with the same name as the event. I need this file to be able to be accessed if needed and saved until the user decides to delete the event. So it's almost like making a calendar app that allows someone to enter an event and keeps that event on the calendar. Even if the app closes, the event should be on the calendar when the user opens the app again. I know I most likely will be using sharedPreferences, bundles, and files, but I don't know how to have my code make a unique file name every time an event is made.

推荐答案

有关确定你需要它在Android上可以与内容提供商使用的源码(数据库)。这样你会得到一个不错的性能和易于使用,测试环境。

For sure you need a sqlite (database) which on android can be used with Content Providers. This way you will get a nice performance and a easy-to-use, testing enviroment.

我建议你检查这一点:

  • Content Providers
  • Content Provider Basics
  • Nice article to get you started

另外,如果你preFER,有很多库,使之更容易使用SQLite和内容提供商的机器人。 greenDAO 是最流行的,但也存在的机械战警并叫的 Android的ContentProvider的发电机

Also, if you prefer, there are a lot of libraries to make it easier to use sqlite and content provider for android. greenDAO is the most popular, but there is also RoBoCoP and a generator for the schema and functions called android-contentprovider-generator

使用数据库也是一个很好的方法,因为如果你有一天(或者你已经这样做)你决定与服务器同步你的数据库,使用ContentProvider的是[相当]简单的任务!

Using a database is also a nice approach because if you someday (or you already do) you decide to sync your db with your server, using ContentProvider is a [quite] simple task !

希望它帮助!

这篇关于如何保存在一个Android应用程序的信息程度的不确定性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆