compilation of Ormliteconfig file in Android studio

我怕爱的太早我们不能终老 提交于 2019-11-28 14:38:41

The pdf doc of ormLite said:

You will need to run this utility locally on your development box (not in an Android device), whenever you make a change to one of your data classes. This means that right now, this must be done by hand to keep the configuration file in sync with your database classes. To run the utility you will need to use the local Java runtime environment (JRE).

Under AndroidStudio, go to "Run" menu, and select "Edit Configurations...", this will make appear an dialog, click on the green button with the plus sign to add a new Run configuration (should be in the left-top corner of the dialog), in the contextual menu you should select "Application".

Next, click on "Main class" input and select your OrmLiteConfigUtil class. In the working directory input you should select the folder where the "res" android file is placed (in the android studio file structure you should have somthing as ".../app/src/main"). Also, select the checkbox "Use alternative JRE" and select a JRE path of a Java Runtime (for me java 7 of oracle works).

finally, click on "Ok" button to save the changes, and it's ready.

create a "raw" directory in your "res" android folder, do this before of run the config.

To run the new config: right click on the file class (your OrmLiteConfigUtil extended class, the same file that you select in the "Main class" input) and select Run '...'. wait for compiler and that is all!, you should see an config file in your res/raw folder

this is some of code for my OrmLiteConfigUtil extended class:

public class DatabaseConfigUtil extends OrmLiteConfigUtil {

    // put all your database classes in this array
    private static final Class<?>[] clases = new Class[]{Vendor.class};

    public static void main(String[] args) throws SQLException, IOException {
        writeConfigFile("ormlite_config.txt", clases);
    }
}

A screenshot of my configuration runner:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!