Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android MySQL从MySQL中插入和提取图像_Android_Mysql_Bitmap - Fatal编程技术网

Android MySQL从MySQL中插入和提取图像

Android MySQL从MySQL中插入和提取图像,android,mysql,bitmap,Android,Mysql,Bitmap,首先,我希望能够用我的手机拍摄图像,使用位图之类的东西,然后将照片上传到MySQL。稍后,我将要撤回应用程序中其他地方的图像 这就是我所拥有的,它无法工作,因为我需要将图像放在文件位置,而不是位图上 public static void InsertImage(String user_id, String gender, Blob image, String filePath) { connection(); //this is where i got my connection inf

首先,我希望能够用我的手机拍摄图像,使用位图之类的东西,然后将照片上传到MySQL。稍后,我将要撤回应用程序中其他地方的图像

这就是我所拥有的,它无法工作,因为我需要将图像放在文件位置,而不是位图上

public static void InsertImage(String user_id, String gender, Blob image, String filePath) {
    connection(); //this is where i got my connection information this works fine btw.

    filePath = "i don't want to have anything here";
    try {
        Connection connect = DriverManager.getConnection(host, username, password);
        PreparedStatement statement = connect.prepareStatement("INSERT INTO picture (user_id, gender, image) VALUES(?, ?, ?)");
        statement.setString(2, user_id);
        statement.setString(3, gender);         
        InputStream inputStream = new FileInputStream(new File(filePath));

        statement.setBlob(8, image);
        statement.executeUpdate();
        statement.close();
        connect.close();
        //3 means column
        System.out.println("Worked");
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

还有,我将如何撤销它?另外,如果使用位图无法工作,因为它是我在mySQL中使用的Blob,那么我还可以使用什么?链接到任何教程将是最好的视频。。我讨厌阅读:s

一般建议:不要在数据库中存储图像。这只会导致以后的痛苦和痛苦。将映像存储在文件系统中,并将有关映像的元数据存储在db.filesystem中?要不要来点硼酸?从没听说过这个词,也没听说过元数据。。这些图像被认为是应用程序的一部分,也就是说,你需要使用互联网来查看它们,等等,现在这是否适用于某种文件系统?因为这听起来像是本地的。