简体   繁体   English

android contentprovider

[英]android contentprovider

I'm a beginner to Android development. 我是Android开发的初学者。 Something always confuses me. 总是让我感到困惑。 Let say if I want to create a simple app that shows all presidents of United States with some brief info, how do I store this information? 假设我要创建一个简单的应用程序,向其显示美国所有总统的简短信息,该如何存储这些信息? Should I store these information in content provider while activity oncreate? 我应该在活动创建时将这些信息存储在内容提供程序中吗? Doesn't it append the data everytime when user start this activity? 用户每次启动此活动时,它是否都不会附加数据?

Should I store these information in content provider while activity oncreate? 我应该在活动创建时将这些信息存储在内容提供程序中吗?

You never store data in a content provider... a content provider is used in order to (guess what?), provide content. 您永远不会将数据存储在内容提供程序中...使用内容提供程序来(猜测什么?)提供内容。 In most cases you won't need to create your own content provider; 在大多数情况下,您无需创建自己的内容提供程序; unless you want to share that data with other apps. 除非您想与其他应用共享该数据。 If the information you are going to handle is going to be used by your app only, don't create content providers... just put your data in a database and access it from there. 如果您要处理的信息仅由您的应用程序使用,则不要创建内容提供程序...只需将数据放入数据库中并从那里访问即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM