on 2012 Jan 03 8:22 AM
Hi All,
I need some help figuring out an issue that I just can't resolve. I'm trying to create a very simple application that uses the UltraLiteJ database/api in an Android 2.2 application. I'm getting an exception when I try to create the database (code and screenshots to follow). The Android sample app works fine, but I just can't figure out where I'm going wrong.
Here is the code (full):
package net.primarysolutions.dbtest; import android.app.Activity; import android.os.Bundle; import android.util.Log; import com.ianywhere.ultralitejni12.ConfigPersistent; import com.ianywhere.ultralitejni12.Connection; import com.ianywhere.ultralitejni12.DatabaseManager; import com.ianywhere.ultralitejni12.PreparedStatement; import com.ianywhere.ultralitejni12.ULjException; public class DBTestActivity extends Activity { private ConfigPersistent m_config; private Connection m_conn; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { try { super.onCreate(savedInstanceState); setContentView(R.layout.main); createDatabase(); } catch (ULjException e) { Log.e("STUFF", e.getMessage()); } } private void createDatabase() throws ULjException { String db_name = "gkanywhere.udb"; m_config = DatabaseManager.createConfigurationFileAndroid(db_name, this.getApplicationContext()); m_config.setLazyLoadIndexes(true); m_conn = DatabaseManager.createDatabase( m_config ); m_conn = DatabaseManager.connect( m_config ); createModules(); } void createModules() throws ULjException { String sql = "CREATE TABLE Modules (" + "Module_Name VARCHAR(30) NOT NULL, " + "Install_Date DATE NULL, " + "License_Expiration DATE NULL, " + "License_Limit INTEGER NULL, " + "Version VARCHAR(20) NULL, " + "PRIMARY KEY ( Module_Name ASC ))"; executeDDL(sql); } private void executeDDL(String sql) throws ULjException { PreparedStatement ps = m_conn.prepareStatement(sql); ps.execute(); ps.close(); } }
The exception is:
Tag = dalvikvm Text = Exception Ljava/lang/UnsatisfiedLinkError; thrown during Lcom/ianywhere/ultralitejni12/implementation/JniDbMgr;.<clinit>
The app wants me to force close at this point when I test against Android 2.2.
I had logging lines in and could tell that it bombs on the line:
m_conn = DatabaseManager.createDatabase( m_config );
I just can't figure out what I'm missing - any help would be greatly appreciated!
Thanks, Calvin
Calvin,
You need to copy the native library libultralitej12.so (and libmlcrsa12.so if you are using https) to libs\\armeabi in your Eclipse project. From there it will get deployed to your device filesystem so that your application can load it. It is needed by UltraLiteJNI12.jar.
FYI - You don't need to call DatabaseManager.connect() after getting a connection with DatabaseManager.createDatabase(). Also, ConfigPersistent.setLazyLoadIndexes() has no effect on Android platforms (it only has an effect on Blackberry).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
67 | |
11 | |
10 | |
10 | |
9 | |
8 | |
6 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.