import java.io.FileOutputStream;
import java.io.IOException;
import java.text.DateFormat;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import android.content.Context;
import android.util.Log;
List<CategoryEntry> crows;
crows = dbHelper.fetchAllCategoryRows();
-
+ HashMap<Long, ArrayList<String>> packageAccess=dbHelper.fetchPackageAccessAll();
+
int totalPasswords=0;
for (CategoryEntry crow : crows) {
totalPasswords++;
serializer.startTag(null, "Entry");
-
+
+ serializer.startTag(null, "RowID");
+ serializer.text(Long.toString(row.id));
+ serializer.endTag(null, "RowID");
+
serializer.startTag(null, "Description");
serializer.text(row.description);
serializer.endTag(null, "Description");
serializer.text(row.note);
serializer.endTag(null, "Note");
- serializer.startTag(null, "UniqueName");
- serializer.text(row.uniqueName);
- serializer.endTag(null, "UniqueName");
+ if (row.uniqueName!=null) {
+ serializer.startTag(null, "UniqueName");
+ serializer.text(row.uniqueName);
+ serializer.endTag(null, "UniqueName");
+ }
+
+ if(packageAccess.containsKey(row.id)) {
+ serializer.startTag(null, "PackageAccess");
+ serializer.text(packageAccess.get(row.id).toString());
+ serializer.endTag(null, "PackageAccess");
+ }
serializer.endTag(null, "Entry");
}
package org.openintents.safe;
import java.text.DateFormat;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import android.content.ContentValues;
import android.content.Context;
return pkgs;
}
+ /**
+ * Fetch all the package access data into one HashMap.
+ *
+ * @return HashMap<Long id, ArrayList<String> package>
+ */
+ public HashMap<Long, ArrayList<String>> fetchPackageAccessAll() {
+ HashMap<Long, ArrayList<String>> pkgsAll=new HashMap<Long, ArrayList<String>>();
+
+ Cursor c = null;
+ try {
+ c =
+ db.query(true, TABLE_PACKAGE_ACCESS, new String[] {
+ "id"}, null, null, null, null, null, null);
+ if (c.getCount() > 0) {
+ c.moveToFirst();
+ while (! c.isAfterLast()) {
+ Long id=c.getLong(0);
+ ArrayList <String> pkgs = fetchPackageAccess(id);
+ if (pkgs!=null) {
+ pkgsAll.put(id, pkgs);
+ }
+ c.moveToNext();
+ }
+ }
+ } catch (SQLException e)
+ {
+ Log.d(TAG,"SQLite exception: " + e.getLocalizedMessage());
+ } finally {
+ if (c != null) c.close();
+ }
+
+ return pkgsAll;
+ }
+
public void addPackageAccess (long passwordID, String packageToAdd) {
ContentValues packageAccessValues = new ContentValues ();
packageAccessValues.put("id", passwordID);
args.put("website", entry.website);
args.put("note", entry.note);
args.put("unique_name", entry.uniqueName);
- DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
- Date date = new Date();
- String timeNow = dateFormat.format(date);
- args.put("lastdatetimeedit", timeNow);
+ DateFormat dateFormatter = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,
+ DateFormat.FULL);
+ Date today = new Date();
+ String dateOut = dateFormatter.format(today);
+ args.put("lastdatetimeedit", dateOut);
try {
db.update(TABLE_PASSWORDS, args, "id=" + Id, null);
} catch (SQLException e)