如何在 android studio 中为扫描图像创建文件路径并添加到 SQL 数据库?
How can I create a filepath for for scanned images in android studio and add to SQL database?
我正在 Android Studio 中创建一个应用程序,我在其中使用外部指纹扫描仪来收集指纹图像。该应用程序的唯一目的是将扫描图像连同每个图像的自定义数据一起存储在 SQL 数据库中,以便将照片用于图像处理项目。我正在使用这个库 https://github.com/shodgson/uareu that allows me to take a photo with the scanner which works perfectly. My problem is how I can create a filepath for the image and put it in an SQL database along with custom data I have added.I tried to implement this method: https://developer.android.com/training/camera/photobasics#java 没有任何运气。
如果您想将图像存储到您的应用程序并且用户看不到您可以使用内部存储。
内部存储是您 phone 中只有您的应用可以访问而用户不能访问的地方。
您可以使用下面的伪代码访问内部存储并创建带有适当后缀的图像文件,例如 .jpg .jpeg 和另一个 .
最后,您必须将图像写入新文件的输出流。
//this is internal storage file
File file = getFilesDir();
File ImageFile = new File(file.getAbsolutePath()+"/"+newFileName.suffix);
try
{
ImageFile.createNewFile();
FileOutputStream fos = new FileOutputStream(ImageFile);
//write your image to file output stream
} catch (IOException e) {
e.printStackTrace();
}
我正在 Android Studio 中创建一个应用程序,我在其中使用外部指纹扫描仪来收集指纹图像。该应用程序的唯一目的是将扫描图像连同每个图像的自定义数据一起存储在 SQL 数据库中,以便将照片用于图像处理项目。我正在使用这个库 https://github.com/shodgson/uareu that allows me to take a photo with the scanner which works perfectly. My problem is how I can create a filepath for the image and put it in an SQL database along with custom data I have added.I tried to implement this method: https://developer.android.com/training/camera/photobasics#java 没有任何运气。
如果您想将图像存储到您的应用程序并且用户看不到您可以使用内部存储。
内部存储是您 phone 中只有您的应用可以访问而用户不能访问的地方。
您可以使用下面的伪代码访问内部存储并创建带有适当后缀的图像文件,例如 .jpg .jpeg 和另一个 .
最后,您必须将图像写入新文件的输出流。
//this is internal storage file
File file = getFilesDir();
File ImageFile = new File(file.getAbsolutePath()+"/"+newFileName.suffix);
try
{
ImageFile.createNewFile();
FileOutputStream fos = new FileOutputStream(ImageFile);
//write your image to file output stream
} catch (IOException e) {
e.printStackTrace();
}