对于ORMLite配置新一代的Andr​​oid工作室的运行配置 [英] Android Studio run configuration for ORMLite config generation

查看:193
本文介绍了对于ORMLite配置新一代的Andr​​oid工作室的运行配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Android Studio和希望使用ORMLite框架。 ORMLite对Android有一个机制,通过表的配置文件使得DAO的创作。

I'm using Android Studio and want to use ORMLite framework. ORMLite for Android has a mechanism for making DAO creation through table config file.

如何设置附加的运行配置在Android的工作室,用于生成这个配置?

How to setup additional Run Configuration in Android Studio for generating this config?

推荐答案

我设法做到这一点,但它是一个有点棘手。

I managed to do it, but it was a little bit tricky.

我有一类称为DatabaseConfigUtil延伸OrmLiteConfigUtil,我遵循ormlite官方教程中创建而已,所以我就假设你做同样的,也有一流的。 请注意,您必须将完整路径传递到配置文件,而不仅仅是文件名然而,在这里它是:

I have a class called DatabaseConfigUtil which extends OrmLiteConfigUtil, that I created just by following the ormlite official tutorial, so I'll just assume you did the same and also have that class. Please note that you have to pass the complete path to the configuration file, instead of just the file name. Nonetheless, here it is:

public class DatabaseConfigUtil extends OrmLiteConfigUtil {
  private static final Class<?>[] classes = new Class[] {
    Class1.class, Class2.class, Class3.class, Class4.class
  };

  public static void main(String[] args) throws SQLException, IOException {
    writeConfigFile(new File("PATH/TO/ANDROID/PROJECT/src/main/res/raw/ormlite_config.txt"), classes);
  }
}

这是我们要以创建ormlite_config.txt执行类。

This is the class we want to execute in order to create the ormlite_config.txt.

在Android Studio项目导航面板,在DatabaseConfigUtil.java单击鼠标右键,选择运行(用绿色箭头的选项)。如果您没有运行配置创建,它会为您创建一个。

In the Android Studio project navigation panel, right-click on the DatabaseConfigUtil.java and select "Run" (the option with the green arrow). If you don't have a Run Configuration created, it will create one for you.

现在,只需编辑配置

在发射之前一节,取出制作。这不是问题,如果在原文件夹中已经有文件ormlite_config.txt,但如果你不这样做,当你运行的类,该项目将编译,这将失败,因为ormlite_config.txt不存在。

In the "Before launch" section, remove the Make. This is not problematic if in the raw folder you already have the file ormlite_config.txt, but if you don't, when you run the class, the project will compile which will fail because the ormlite_config.txt doesn't exist.

现在再次运行该项目。

一切都应该能够顺利走了。

Everything should go smoothly now.

干杯

这篇关于对于ORMLite配置新一代的Andr​​oid工作室的运行配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆