简体   繁体   English

将uri存储在mysql数据库中的最佳方法

[英]Best way to store uri in mysql database

I have an android app in which a user registers using his/her facebook account, and I want to get that user's profile picture, the method that the sdk offers returns the URI(i) for that profile picture, I want to send this uri to my php server and then store it in mysqldata base, and because I new to this I have a bunch of questions: What is the best way (field) to store the uri in my server database? 我有一个Android应用程序,其中用户使用他/她的facebook帐户注册,我想获取该用户的个人资料图片,sdk提供的方法返回该个人资料图片的URI(i),我想发送此uri到我的php服务器,然后将其存储在mysqldatabase中,由于这是我的新手,所以我有很多问题:将uri存储在服务器数据库中的最佳方法(字段)是什么? I ll be doing in further steps some http request to download that picture, and the method I implemented to download a picture from a web server uses URLs, will I have issues in using the URI? 我将在进一步的步骤中执行一些http请求以下载该图片,并且实现从Web服务器下载图片的方法使用URL,使用URI是否会遇到问题? Is there other issues that I ll have to be aware of in using URIs? 使用URI时,我还有其他问题要注意吗? Thank u in advance. 预先谢谢你。

As has been commented, the best way is to store it is in its String form. 如前所述,最好的方法是以String形式存储它。

You can store the Uri using the toString method and when you get it back from your database later, you can use the Uri.parse(String) method to get it back into a Uri object. 您可以使用toString方法存储Uri ,稍后从数据库中取回Uri时,可以使用Uri.parse(String)方法将其取回Uri对象。

To answer your other questions... 要回答您的其他问题...

the method I implemented to download a picture from a web server uses URLs, will I have issues in using the URI? 我实现的从Web服务器下载图片的方法使用URL,使用URI是否会出现问题?

This shouldn't be a problem as it's a fairly simple task to convert from a Uri to a URL. Uri转换为URL是一项相当简单的任务,这应该不成问题。

Is there other issues that I ll have to be aware of in using URIs? 使用URI时,我还有其他问题要注意吗?

One thing to note is that Android has two types of Uri available in the SDK. 需要注意的一件事是,Android在SDK中提供了两种类型的Uri。 The one in the android.net package (the one I referred to above) and also the one from the Java SDK . android.net包中的一个(我上面提到的一个),还有Java SDK中的一个 I would recommend you familiarise yourself with the available classes and decide which one is more suitable for your purposes. 我建议您使自己熟悉可用的类,并确定哪一种更适合您的目的。

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

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