简体   繁体   English

连接到MySQL数据库并将DB放置在Android手机上

[英]Connecting to a MySQL DB and putting the DB on an android phone

Right now in my app I connect to a MySQL DB as a "as needed" for getting information on a online game I play (the app is a sort of information based and a performance enhancer for game-play), but I now find myself seeing that on an orientation change or just hitting back and going back into the same section of the app I always have this loading that needs to happen which even to me gets me a bit upset/frustrated on the wait time that needs to be done which will disturb the user experience which I 100% want to avoid. 现在,在我的应用程序中,我作为“需要”连接到MySQL数据库,以获取有关我玩的在线游戏的信息(该应用程序是一种基于信息的信息,是游戏性能的增强器),但现在我发现自己看到方向改变或只是回头再回到应用程序的同一部分时,我总是需要进行这种加载,这甚至对我来说也让我对需要完成的等待时间有些沮丧/沮丧会干扰我100%希望避免的用户体验。

So my questions on this was: 所以我对此的疑问是:

  1. How can I get the entire MySQL DB onto the phone quickly and efficiently? 如何快速有效地将整个MySQL数据库安装到手机上?

  2. When the app exits does the DB table still reside there on the phone? 当应用程序退出时,DB表是否仍驻留在手机上?

How can I get the entire MySQL DB onto the phone quickly and efficiently? 如何快速有效地将整个MySQL数据库安装到手机上?

You probably can't. 你可能不会。 That database could be anywhere from 1.1x - 300x the size of your available device's capacity. 该数据库的大小可能是可用设备容量的1.1倍-300倍。 The occasional calls to retrieve only what it needs are more efficient than trying to pump (potential) gigabits to its clients. 偶尔调用仅检索其需要的调用比尝试将(潜在的)千兆字节泵送给其客户要有效。

When the app exits does the DB table still reside there on the phone? 当应用程序退出时,DB表是否仍驻留在手机上?

This is strongly dependent on the implementation of the application. 这在很大程度上取决于应用程序的实现。 If there's a justification to cache that kind of data (I'd presume info such as countries or dates or constant values would stick around), then it might. 如果有理由缓存这种数据(我想假设国家或日期之类的信息或常量值会一直存在),那么可能会。 Otherwise, you'd be better off taking it up with the developer themselves. 否则,最好与开发人员自己合作。

I'm not entirely familiar with Android (yet), but at some point in the lifecycle of an application, typically on an orientation change, the application itself is destroyed/recreated for that orientation. 我尚未完全熟悉Android(但),但是在应用程序生命周期的某个时刻,通常是在方向更改时,会针对该方向破坏/重新创建应用程序本身。 It could be that the work to connect to the DB is done in an inappropriate layer, hence why you're seeing such poor performance. 连接数据库的工作可能是在不适当的层完成的,因此为什么您会看到如此差的性能。

You'd really want to take this up with the developer. 您真的想与开发人员接洽。 If you don't have the source code to change this, there's not much we can suggest that will help. 如果您没有源代码来更改此设置,那么我们可以提供很多建议。

I want to help you, but I need more information about your problem. 我想为您提供帮助,但我需要有关您的问题的更多信息。

What version of MySQL you are using? 您正在使用哪个版本的MySQL?

You can use SQLite or save and load the data from a xml file. 您可以使用SQLite或保存并从xml文件加载数据。

Regards, 问候,

You have not to get everything from the database. 您不必从数据库中获取所有内容。 You just need load the information needed for application. 您只需要加载应用程序所需的信息。

How to get from a MySql server to an Android app? 如何从MySql服务器转到Android应用程序?

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

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