gpt4 book ai didi

java - 如何在android中运行main

转载 作者:行者123 更新时间:2023-11-29 06:41:11 24 4
gpt4 key购买 nike

大家好,我正在编写简单的应用程序来训练我的 ContentProvider 技能。所以我编写了 Contract 类,它指定了所有故事的所有元数据

public class StoreContract {

public static String AUTHORITY = "com.ura.store.intentProvider";
public static String DATABASE_NAME = "Store.db";

public static class Customer{
public static final String TABLE_NAME ="tblCustomers";
public static final String COLUMN_AUTO_ID = "_id";
public static final String COLUMN_NAME="First Name";
public static final String COLUMN_LAST_NAME = "Last name";
public static final String COLUMN_PHONE_NUMBER = "Phone number";

public static final String CREAT_STRING = "create table "+TABLE_NAME+
" ( "+COLUMN_AUTO_ID+" INTEGER PRIMARY KEY AUTOINCREMENT , "
+COLUMN_NAME+" TEXT , "
+COLUMN_LAST_NAME+" TEXT , "
+COLUMN_PHONE_NUMBER+" TEXT);";
}

static class Seller{
public static final String TABLE_NAME = "tblEmployes";
public static final String COLUMN_AUTO_ID = "_id";
public static final String COLUMN_NAME="First Name";
public static final String COLUMN_LAST_NAME = "Last name";
public static final String COLUMN_EMPLOY_TYPE = "Type";
public static final String CREAT_STRING = "create table "+TABLE_NAME+
" ( "+COLUMN_AUTO_ID+" INTEGER PRIMARY KEY AUTOINCREMENT , "
+COLUMN_NAME+" TEXT , "
+COLUMN_LAST_NAME+" TEXT , "
+COLUMN_EMPLOY_TYPE+" TEXT);";

}

static class Buy{
public static final String TABLE_NAME = "tblBuys";
public static final String COLUMN_AUTO_ID = "_id";
public static final String COLUMN_CUSTOMER_ID = "Customer";
public static final String COLUMN_SELLER_ID = "Seller";
public static final String COLUMN_INFO = "Info";
public static final String COLUMN_PRICE = "Price";
public static final String CREAT_STRING = "create table "+TABLE_NAME+
" ( "+COLUMN_AUTO_ID+" INTEGER PRIMARY KEY AUTOINCREMENT , "
+COLUMN_CUSTOMER_ID+" TEXT, "
+COLUMN_SELLER_ID+" TEXT , "
+COLUMN_INFO+" TEXT "
+COLUMN_PRICE+" REAL"
+"FOREIGN KEY("+COLUMN_CUSTOMER_ID+") REFERENCES "+Customer.TABLE_NAME+"("+Customer.COLUMN_AUTO_ID+")"
+"FOREIGN_KEY("+COLUMN_SELLER_ID+") REFERENCES "+Seller.COLUMN_AUTO_ID+"("+Seller.COLUMN_AUTO_ID+")";
}

public static void main(String []args){
System.out.println(StoreContract.Customer.CREAT_STRING);
}

注意我写它的主要方法是为了看看我的表创建字符串看起来如何当然该方法不起作用可能是因为它是 Android 项目。所以我的问题很简单在这种情况下你建议做什么我意味着除了将所有类复制并传递给其他项目外,我很确定对于这些东西有一个标准的解决方案,一些单元测试或其他东西。
谢谢:)

最佳答案

Android 中 main 方法的等价物是 onCreate()在 Activity 中(以及几乎所有其他地方)

关于java - 如何在android中运行main,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11799462/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com