我是 Android 的新手,我正在尝试将 SQLite 与 Active Android ORM 结合使用。我有一个简单的待办事项应用程序,我正在按照教程设置 Activity 的 android。但是,它不会告诉您实际放置模型文件的位置。
https://github.com/pardom/ActiveAndroid/wiki/Getting-started
我相信我的 AndroidManifest.xml 设置正确,但我不知道将类放在实际设置模型的位置。教程中提供了这个 fragment ,但我不知道它去了哪里
public class MyApplication extends SomeLibraryApplication {
@Override
public void onCreate() {
super.onCreate();
ActiveAndroid.initialize(this);
}
}
此外,我是否在 app/java/com.blahblah 中创建一个新文件并在那里声明我的表?
任何关于如何构建它的帮助都将被应用
最佳答案
真的很简单。添加应用程序类后,确保将其添加到 list 中:
<application ***android:name=".MyApplication"*** android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" >
只需确保将任何模型类添加到 list 中即可。以下是我的 list 如何查找上述结构:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.dbtest" > <application android:name=".MyApplication" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!-- Set a name for your database --> <meta-data android:name="AA_DB_NAME" android:value="SomeDatabaseName.db" /> <meta-data android:name="AA_DB_VERSION" android:value="5" /> <!-- All of your models (tables) go here, separated by coma --> <meta-data android:name="AA_MODELS" android:value="com.example.dbtest.models.Item, com.example.dbtest.models.Category" /> </application> </manifest>
我想这就是它的全部。
关于java - ActiveAndroid 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32769988/