Skip to Content
0
Former Member
Dec 10, 2012 at 06:05 PM

Android Native application with SUP:

24 Views

Dear All,

I am getting the following error while trying out simple scenario with android, it seems it is failing while creating the database.

I used the following code.

public class MainActivity extends Activity implements OnClickListener {

private static String USERNAME = "supAdmin";

private static String PASSWORD = "supAdmin";

private static String HOST = "10.10.0.10" ;

private static int PORT = 5001;

private static int TIMEOUT = 600;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Button button = (Button)findViewById(R.id.button1);

button.setOnClickListener(this);

Application app = Application.getInstance();

app.setApplicationIdentifier("FLIGHT");

app.setApplicationContext(MainActivity.this);

// step1 : Before registering the application set the connection properties

ConnectionProperties connProps = app.getConnectionProperties();

connProps.setServerName(HOST);

connProps.setPortNumber(PORT);

connProps.setActivationCode("123");

connProps.setFarmId("0");

FLIGHTDB.setApplication(app);

LoginCredentials loginCredentials = new LoginCredentials(USERNAME, PASSWORD);

connProps.setLoginCredentials(loginCredentials);

//Step2: Registration

if(app.getRegistrationStatus() != RegistrationStatus.REGISTERED)

{

app.registerApplication(TIMEOUT);

connProps.setActivationCode("123");

}

else

{

app.startConnection(TIMEOUT);

}

// Step3: set Property for Synchronization

ConnectionProfile profile = FLIGHTDB.getSynchronizationProfile();

profile.setServerName(HOST);

profile.setPortNumber(2480);

profile.setNetworkProtocol("http");

profile.setAsyncReplay(true);

profile.setDomainName("default");

profile.save();

if(!FLIGHTDB.databaseExists()){

FLIGHTDB.createDatabase();

FLIGHTDB.synchronize();

}

else{

FLIGHTDB.deleteDatabase();

FLIGHTDB.createDatabase();

}

FLIGHTDB.openConnection();

// Step4: Synchronize

if (!FLIGHTDB.isSynchronized("default"))

{

FLIGHTDB.disableChangeLog();

FLIGHTDB.synchronize(); // Initial Synchronize

SynchronizationGroup sg = FLIGHTDB.getSynchronizationGroup("default");

sg.setEnableSIS(true);

sg.save();

FLIGHTDB.synchronize();

}

FLIGHTDB.enableChangeLog();

}

@Override

public void onClick(View arg0) {

int count = 0;

TextView view = (TextView)findViewById(R.id.tv1);

Query query = new Query();

query.select("count(*)");

query.from("FLIGHT_LIST", "x");

QueryResultSet rs = FLIGHTDB.executeQuery(query);

if (rs != null) {

rs.next();

count = rs.getInt(1);

}

if (count == 0) {

count = 1;

}

view.setText(count);

}

}

Someone kindly help me find out what am I doing wrong here.I am new to Android and Java.

Attachments

pastedImage_2.png (22.5 kB)