[Q] Problem with DB development since using Galaxy S III - Galaxy S III Q&A, Help & Troubleshooting

Hey guys,
I hope, that this problem has not been discussed somewhere else because my search did not bring me a result...
I have the problem, that my database application, which worked quite good on my Galaxy S I9000 do not work on my new Galaxy S III. I can run the application as usual, but as soon as I restart my OS, the complete databases are gone, even if they have been available before the restart...
Is there anything, that has changed from Galaxy S to Galaxy S III or is it an issue related to ICS???
This is the code I used to create and initialize the DB:
Code:
SQLiteDatabase sqlite = Constants.getMain().openOrCreateDatabase("MyMFGDB", Context.MODE_PRIVATE, null);
//Debug only
sqlite.execSQL("DROP TABLE IF EXISTS fahrt");
sqlite.execSQL("DROP TABLE IF EXISTS mitfahrer");
sqlite.execSQL("DROP TABLE IF EXISTS fahrt_mitfahrer");
sqlite.execSQL("CREATE TABLE IF NOT EXISTS fahrt (id INTEGER PRIMARY KEY," +
"start text NOT NULL,ziel text NOT NULL,datum date NOT NULL," +
"kosten int(11) DEFAULT NULL,version int(11) NOT NULL DEFAULT '1'," +
"del int(1) NOT NULL DEFAULT '0')");
sqlite.execSQL("CREATE TABLE IF NOT EXISTS mitfahrer (id INTEGER PRIMARY KEY," +
"nummer bigint(20) NOT NULL,name text,bad int(1) NOT NULL DEFAULT '0'," +
"kommentar text,version int(11) NOT NULL DEFAULT '1'," +
"del int(1) NOT NULL DEFAULT '0')");
sqlite.execSQL("CREATE TABLE IF NOT EXISTS fahrt_mitfahrer (id INTEGER PRIMARY KEY," +
"mitfahrer_id int(11) NOT NULL,fahrt_id int(11) NOT NULL,start text NOT NULL," +
"ziel text NOT NULL,wait int(1) NOT NULL DEFAULT '0', kommentar text,version int(11) NOT NULL DEFAULT '1'," +
"del int(1) NOT NULL DEFAULT '0', " +
"FOREIGN KEY (fahrt_id) REFERENCES fahrt(id)," +
"FOREIGN KEY (mitfahrer_id) REFERENCES mitfahrer(id) )");
Please feel free to ask any questions.
It would be great to hear from you soon!
Thanks for your help!
Stefan

Hi again,
I have to correct me, I was wrong, when I said, that it is deleted only at the restart. It is also deleted after a certain time when the phone is not rebooted...
I really do not understand, why this is happening.
Do I have to set any other parameters to store the DB permanently to the phone?

Related

[Q] Cannot get a android sqlite select statement to work !

Hi guys,
I'm trying to select the items that have a expiration date >= that an selected date.
I'm using the format yyyy-mm-dd, and this is my sql statement:
String sql = "SELECT _id, item, value, finalDate FROM "+DATABASE_TABLE+" WHERE date(finalDate) >= date("+selectedDate+")";
This query always result a "full select" in my database, as if there were no conditions.
Some useful information:
selectDate is a String which have a date in yyyy-mm-dd format
I'm executing the query like this:
return db.rawQuery(sql,null);
I think it has to do with the quotes
Try:
String sql = "SELECT _id, item, value, finalDate FROM "+DATABASE_TABLE+" WHERE date(finalDate) >= date('" +selectedDate+ "')";
OR
String sql = "SELECT _id, item, value, finalDate FROM "+DATABASE_TABLE+" WHERE date('finalDate') >= date('" +selectedDate+ "')";
I am not 100% sure that will work but my code looks like this ( that works )
public Cursor fetchMedicineEventByDate(String date) {
return mDb.query(DATABASE_MEDICINEEVENT_TABLE,
new String[] { DATABASE_MEDICINEEVENT_ID,
DATABASE_MEDICINEEVENT_AMOUNT,
DATABASE_MEDICINEEVENT_MEDICINETYPEID,
DATABASE_MEDICINEEVENT_TIMESTAMP,
DATABASE_MEDICINEEVENT_USERID }, "date("
+ DATABASE_MEDICINEEVENT_TIMESTAMP + ") " + " = "
+ "date('" + date + "')", null, null, null, null);
}
This give me all items from the given date ( i use the query method but im sure it will work with rawquery to )
If it works please say so and press thanks
I was missing the quotes, like you said ! Thanks a lot !
gkenny1991 said:
I think it has to do with the quotes
Try:
String sql = "SELECT _id, item, value, finalDate FROM "+DATABASE_TABLE+" WHERE date(finalDate) >= date('" +selectedDate+ "')";
OR
String sql = "SELECT _id, item, value, finalDate FROM "+DATABASE_TABLE+" WHERE date('finalDate') >= date('" +selectedDate+ "')";
I am not 100% sure that will work but my code looks like this ( that works )
public Cursor fetchMedicineEventByDate(String date) {
return mDb.query(DATABASE_MEDICINEEVENT_TABLE,
new String[] { DATABASE_MEDICINEEVENT_ID,
DATABASE_MEDICINEEVENT_AMOUNT,
DATABASE_MEDICINEEVENT_MEDICINETYPEID,
DATABASE_MEDICINEEVENT_TIMESTAMP,
DATABASE_MEDICINEEVENT_USERID }, "date("
+ DATABASE_MEDICINEEVENT_TIMESTAMP + ") " + " = "
+ "date('" + date + "')", null, null, null, null);
}
This give me all items from the given date ( i use the query method but im sure it will work with rawquery to )
If it works please say so and press thanks
Click to expand...
Click to collapse
no problem this can be locked now

[Q] ClockworkMod wipe blocking encryption?

Hi guys and gals,
I've been investigating why I can't enable encryption on either of my phones running CM9. I'm getting this error in logcat when I go to enable:
E/Cryptfs ( 1454): Orig filesystem overlaps crypto footer region. Cannot encrypt in place.
What I've discovered is that the dmcrypt layer requires 16kb of space at the end of the /data partition to store its volume keys. In the case of my HOX, stock recovery is smart enough to reserve those last blocks. But from what I can tell, CWM when it formats /data (to perform a wipe) formats the entire partition.
By passing an option for number of blocks (n where n is the total number of blocks - (16/blocksize)) to mke2fs at wipe time it should reserve enough space for encryption.
Looking at the cwm recovery source, I found this code for formatting ext4 volumes such as /data:
Code:
if (strcmp(fs_type, "ext4") == 0) {
int length = 0;
if (strcmp(v->fs_type, "ext4") == 0) {
// Our desired filesystem matches the one in fstab, respect v->length
length = v->length;
}
reset_ext4fs_info();
int result = make_ext4fs(device, length);
if (result != 0) {
LOGE("format_volume: make_extf4fs failed on %s\n", device);
return -1;
}
return 0;
}
So there is already a provision for a length option. The v variable is an array built from this code:
Code:
Volume* volume_for_path(const char* path) {
int i;
for (i = 0; i < num_volumes; ++i) {
Volume* v = device_volumes+i;
int len = strlen(v->mount_point);
if (strncmp(path, v->mount_point, len) == 0 &&
(path[len] == '\0' || path[len] == '/')) {
return v;
}
}
return NULL;
}
device_volumes appears to be populated from fstab, and from what i can see length will always be 0 (??) which i assume tells mkfs to always format the entire volume.
Perhaps someone more familiar with CWM's code paths (I'm a little lost) could explain how to get CWM to format the volume reserving the last 16kb?
Close, but the actual code in question is the following in bootable/recovery/roots.c:
Code:
static int parse_options(char* options, Volume* volume) {
char* option;
while (option = strtok(options, ",")) {
options = NULL;
if (strncmp(option, "length=", 7) == 0) {
volume->length = strtoll(option+7, NULL, 10);
...
That's reading the options from /etc/recovery.fstab (using roots.c:load_volume_table()). So all you need to do is make sure your device's recovery.fstab specifies the correct length. This is easiest done using a negative offset length of 16384. So, for a One X, update device/htc/endeavoru/recovery.fstab to add "length=-16384" to the end of the line for /data. For an example, see https://github.com/CyanogenMod/android_device_htc_pyramid/blob/ics/recovery.fstab.
While it would be better if indeed CWM was made smart enough to deal with this, I did make in the mean time a patch you can apply after a wipe to shrink the partition
cybermaus said:
While it would be better if indeed CWM was made smart enough to deal with this, I did make in the mean time a patch you can apply after a wipe to shrink the partition
Click to expand...
Click to collapse
Just played a bit with CM10.2 on my SGS3. To be honest I don't get this issue with partition size. Could you please help me to understand the following: why do we need to resize the partition if the stock ROM does not do it, neither in runtime (when encrypting) nor in flashing new ROM? How does it work on the stock ROM in comparison to CM? What's different? I'm afraid to resize the partition before I understand why I must do it (I read about this 16kb, I fully understand it, but I don't get why it's not needed by the stock ROM).
Thanks!
Maciej

[Q] GoogleMap resets and stops responding

Hi all..
I am not sure this is the right sub-forum to post in, but here goes.
I am working on an app that uses a GoogleMap and lots of overlays/markers. Controls and navigation is handled automatically (no direct user interaction with the map needed so far).
Things work the way I want right until the app pauses and goes into the background. When I resume the app the map has zoomed out to 0:0 and it doesn't react to animateMap or anything anymore. I can't seem to figure how I get it back to the state where it doesn't react to user interaction and actually updates with my markers and stuff..
Below are the three methods handling the map, and it doesn't seem to react on any of it after a resume. Any hints?
Code:
private void setupMap(){
getSupportFragmentManager().beginTransaction().replace(R.id.trackeractivity_map, new SupportMapFragment()).commit();
FragmentManager fragmentManager = getSupportFragmentManager();
SupportMapFragment supportMapFragment = (SupportMapFragment) fragmentManager.findFragmentById(R.id.trackeractivity_map);
mMap = supportMapFragment.getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mMap.setMyLocationEnabled(true);
Log.d(TAG, "Max zoom level " + mMap.getMaxZoomLevel());
}
private void updateUserLocation(double lat, double lon){
Log.d(TAG, "updateUserLocation - " + lat + " : " + lon);
mLastLocationLat = lat;
mLastLocationLon = lon;
CameraPosition userPos = new CameraPosition(new LatLng(lat, lon), mMap.getMaxZoomLevel()-4, 0, 0);
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(userPos));
}
private void updateMapOverlay(double lat, double lon){
Log.d(TAG, "updateMapOverlay - " + lat + " : " + lon + " - Type " + mCurrentType);
MarkerOptions marker = new MarkerOptions();
marker.position(new LatLng(lat, lon));
marker.draggable(false);
marker.icon(BitmapDescriptorFactory.fromResource(getTypeDrawableID(mCurrentType)));
mMap.addMarker(marker);
}
Try to re flash Google apps package or restore any previous nandroid backup
FRIEND IF I HELPED YOU HIT THANKS
Androyash said:
Try to re flash Google apps package or restore any previous nandroid backup
FRIEND IF I HELPED YOU HIT THANKS
Click to expand...
Click to collapse
That, unfortunately, didn't help.. Still does the same thing.. Bugs the crap out of me..
Maybe it is just me, but how do i set UISettings on the map? There only seems to be a method to get them?
https://developers.google.com/maps/...erence/com/google/android/gms/maps/UiSettings

[Q] prevent android from storing plain text wifi passwords [solved]

Hey,
a few months ago I read somewhere that android stores the wifi passwords in plain text (seems to be known since 2010: http://forum.xda-developers.com/showthread.php?t=794555 but no one cares?!)
Because I don't want my wifi password to be stored that way, I searched for a way to store the wpa passphrase. This wasn't difficult, because android usese wpa_supplicant, means I just had to find out my passphrase and replace the plain key in /data/misc/wifi/wpa_supplicant.conf with it. Everything still works fine and my phone is able to connect to wifi.
Now my question is: is there a way to store every new wifi password this way? It's annoying to have to edit the wpa_supplicant.conf file manually...
One problem is, that it seems like android doesn't have the wpa_passphrase binary included, even if the source code seems to exist in the wpa_supplicant repository ( https://android.googlesource.com/platform/external/wpa_supplicant_6/ ).
If someone could tell me, how to build the code (I'm not familiar with the ndk), I could try writing an app, which replaces all plain text passwords with the passphrases.
But it would be awesome, if it were possible to integrate this feature in a custom rom, so no more passwords are stored plain text.
Best regards,
David
Finally, I was able to build CarbonRom from source and found a way to integrate this in the rom! On my device, no wifi password is stored in plain text anymore It took a long time to figure out what file I have to change but finally, I got it
If you are interested, I could create a patch and post it here but I don't know how to submit patches to github.
The only thing that confuses me: I found out, that the SSID I use to generate the password hash is quoted. Means, ThisIsASSID is stored as "ThisIsASSID". But actually the password hash should be wrong because it doesn't use ThisIsASSID. Anyway, it works And the password in wpa_supplicant.conf is hashed.
Edit: Cheered too soon... The wpa_supplicant.conf is probably just read at boot time. After a reboot I couldn't connect to my wifi anymore... But if I change the hash in the wpa_supplicant.conf file manually to the right one it works, so now I have to solve the quoting thing. But that shouldn't be difficult.
So, all problems solved now
Here is a patch I created, if anyone is interested:
PHP:
--- original/external/wpa_supplicant_8/wpa_supplicant/config_file.c 2013-08-15 00:12:50.000000000 +0200
+++ carbon/external/wpa_supplicant_8/wpa_supplicant/config_file.c 2013-08-15 01:09:21.876028461 +0200
@@ -19,6 +19,7 @@
#include "p2p/p2p.h"
#include "eap_peer/eap_methods.h"
#include "eap_peer/eap.h"
+#include "crypto/sha1.h"
static int newline_terminated(const char *buf, size_t buflen)
@@ -483,10 +484,36 @@
static void write_psk(FILE *f, struct wpa_ssid *ssid)
{
+ unsigned char psk[32];
char *value = wpa_config_get(ssid, "psk");
- if (value == NULL)
+ char *s = wpa_config_get(ssid, "ssid");
+ if(value == NULL || s == NULL)
return;
- fprintf(f, "\tpsk=%s\n", value);
+ int slen = os_strlen(s);
+ int plen = os_strlen(value);
+ int pskquoted = (value[0] == '"' && value[plen - 1] == '"') ? 1 : 0;
+ int i;
+ //if passphrase length is 64 it's already hashed as well as hashed passphrases aren't quoted
+ if( pskquoted == 1 || plen < 64){
+ //Check for quotes and remove if necessary
+ if(s[slen - 1] == '"' && s[0] == '"') {
+ s[slen - 1] = '\0';
+ s++;
+ }
+ if(pskquoted == 1) {
+ value[plen - 1] = '\0';
+ value++;
+ }
+ //Hash passphrase
+ pbkdf2_sha1(value, (u8 *) s, os_strlen(s), 4096, psk, 32);
+ fprintf(f, "\tpsk=");
+ for (i = 0; i < 32; i++)
+ fprintf(f, "%02x", psk[i]);
+ fprintf(f, "\n");
+ } else {
+ fprintf(f, "\tpsk=%s\n", value);
+ }
+ os_free(s);
os_free(value);
}
I didn't found a place in the java code so I directly edited the c code of wpa_supplicant

[Q] What the correct way to read from thumb_image column on messages table (Whatsapp)

Hi all,
I build a software for myself that read from Whatsapp db (that stored on my android device)..
I trying to read from thumb_image column but cannot find the correct way ...
I write this software on c# language... and the code for read its column as follows:
//thumbImage is the value that stored in thumb_image column.
byte[] encodedbytes = System.Text.Encoding.Unicode.GetBytes(thumbImage);
string encoded = System.Convert.ToBase64String(encodedbytes);
byte[] utf8Decoded = System.Text.Encoding.UTF8.GetBytes(encoded);
File.WriteAllBytes("Images\\" + mdeiaName, utf8Decoded);
but it's not working, so i trying to use IronPython as following:
string pythonScript = @"import base64
class DecryptString(object):
def Decrypt(self, str):
return base64.b64encode(str).decode(""utf-8"")";
ScriptEngine engine = Python.CreateEngine();
ScriptSource source = engine.CreateScriptSourceFromString(pythonScript);
ScriptScope scope = engine.CreateScope();
source.Execute(scope);
dynamic DecryptString = scope.GetVariable("DecryptString");
dynamic decryptString = DecryptString();
var result = decryptString.Decrypt(thumbImage);
File.WriteAllText("Images\\" + mdeiaName, result);
but without success...
Can somebody help me?

Categories

Resources