【问题标题】:ActiveAndroid setupActiveAndroid 设置
【发布时间】:2015-09-25 04:34:46
【问题描述】:

我是 Android 新手,我正在尝试将 SQLite 与 Active Android ORM 一起使用。我有一个简单的待办事项应用程序,我正在按照教程设置活动的 android。但是,它并没有告诉您实际放置模型文件的位置。

https://github.com/pardom/ActiveAndroid/wiki/Getting-started

我相信我的 AndroidManifest.xml 设置正确,我不知道在哪里放置你实际设置模型的类。教程中提供了这个 sn-p 但我不知道它在哪里

public class MyApplication extends SomeLibraryApplication {
    @Override
    public void onCreate() {
        super.onCreate();
        ActiveAndroid.initialize(this);
    }
}

另外,我是否在 app/java/com.blahblah 中创建一个新文件并在那里声明我的表?

如果有任何关于如何构建它的帮助,我们将不胜感激

【问题讨论】:

    标签: java android activeandroid


    【解决方案1】:

    真的很简单。添加应用程序类后,请确保将其添加到清单中:

    <application
        ***android:name=".MyApplication"***
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
    

    至于你把模型放在哪里,这并不重要。您可以具有以下结构:

    只需确保将任何模型类添加到清单中。以下是我的清单查找上述结构的方式:

    <?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>
    

    我想这就是它的全部。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-17
      • 1970-01-01
      相关资源
      最近更新 更多