<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
# Project target.
target=android-17
-android.library.reference.1=../gridlayout_v7
package ro.ieval.unical;
+import android.content.ContentValues;
import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
public class DatabaseInteract {
private SQLiteDatabase database;
private MySQLiteHelper dbHelper;
+ private String[] allColumns = {
+ MySQLiteHelper.ID, MySQLiteHelper.title,
+ MySQLiteHelper.description, MySQLiteHelper.date,
+ MySQLiteHelper.duration, MySQLiteHelper.repeat,
+ MySQLiteHelper.repeatIn, MySQLiteHelper.location
+ };
public DatabaseInteract(Context context) {
dbHelper = new MySQLiteHelper(context);
dbHelper.close();
}
- //Add event
+ //Insert event
+ public void insertEvent(Event e) {
+ ContentValues values = new ContentValues();
+ values.put(allColumns[1],e.title);
+ values.put(allColumns[2],e.description);
+ values.put(allColumns[3],e.date);
+ values.put(allColumns[4],e.duration);
+ values.put(allColumns[5], e.repeat);
+ values.put(allColumns[6], e.repeatInterval);
+ values.put(allColumns[7], e.location);
+ database.insert(MySQLiteHelper.Name, null, values);
+ }
//Delete event
//Search event
}
package ro.ieval.unical;
public class Event {
- public int date,time;
+ public int date,duration;
public boolean repeat;
public int repeatInterval;
public String location;
public static final String Name="Events";
public static final String ID = "_id";
- public static final String name = "Name";
+ public static final String title = "Title";
public static final String description = "Description";
public static final String date = "Date";
- public static final String time = "Time";
+ public static final String duration = "Duration";
public static final String repeat = "repeat";
public static final String repeatIn = "repeatInterval";
public static final String location = "Location";
private static final String Database_create = "create table " + Name + "(" +
ID + " integer primary key autoincrement, " +
- name + " text not null, " +
+ title + " text not null, " +
description + " text, " +
date + " integer, " +
- time + " integer, " +
+ duration + " integer, " +
repeat + " integer, "+
repeatIn + " integer, " +
location + " text);"
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Date;
+import javax.net.ssl.HttpsURLConnection;
+
import ro.ieval.unical.R;
import com.google.gson.Gson;
InputStreamReader in;
try {
hostUrlJson=new URL(Constants.searchUrl);
- URLConnection calConnection = hostUrlJson.openConnection();
- calConnection.setRequestProperty("Authorization", "Basic "+Base64.encodeToString( (Constants.user+':'+Constants.password).getBytes(), Base64.NO_WRAP));
+ HttpsURLConnection calConnection = (HttpsURLConnection) hostUrlJson.openConnection();
+ calConnection.setDoOutput(true);
+ calConnection.setUseCaches(false);
+ //calConnection.setRequestProperty("Authorization", "Basic "+Base64.encodeToString( (Constants.user+':'+Constants.password).getBytes(), Base64.NO_WRAP));
+ //calConnection.setRequestMethod("POST");
+ //calConnection.setDoInput(true);
+ //calConnection.connect();
+
+ final PrintWriter ps=new PrintWriter(calConnection.getOutputStream());
+ ps.print("{}");
+ ps.close();
+
in = new InputStreamReader(calConnection.getInputStream());
Gson gson=new Gson();
events=gson.fromJson(in,Event[].class);
in.close();
+
return events;
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
final TextView date=(TextView) findViewById(R.id.date);
final TextView description=(TextView) findViewById(R.id.description);
super.onCreate(savedInstanceState);
- System.err.println("MuieLaComisie");
+
final Handler h=new Handler();
new Thread(new Runnable() {
public void run() {
eventTitle.setText(events[0].title);
date.setText((new Date(events[0].date)).toString());
description.setText(events[0].description);
+ //DatabaseInteract db=new DatabaseInteract(null);
+ //db.insertEvent(events[0]);
}
});
}