[Q] Issues reading contact's phone numbers - Galaxy S III Q&A, Help & Troubleshooting

This would better be located in Galaxy S III Android Development forum, but apparently I can't post there yet as I have fewer than 10 posts. Moderators, please move this to that forum.
I am a new developer to Android. I wrote a simple program that tries to figure out which contacts are most called to. The program works just fine on the emulator, but fails to work on my Samsung S3. Specifically, I can not read the list of phone numbers of a particular contact. What I see is that ContactsContract.Contact._ID does not correspond to the ContactsContract.Data.RAW_CONTACT_ID. For example, I have a contact in my phone called "Mailbox abhören" ("voice mail"), which has a phone number +491793000333. In the ContactsContract.Contact I see two relevant entries (dumped using this code: http://tny.cz/95e6124e):
Code:
_ID = 1087
LOOKUP_KEY = 4063i27e12adb8d7365fe
DISPLAY_NAME = Mailbox abhören
DISPLAY_NAME_PRIMARY = Mailbox abhören
PHOTO_ID = null
PHOTO_URI = null
PHOTO_THUMBNAIL_URI = null
IN_VISIBLE_GROUP = 1
HAS_PHONE_NUMBER = 1
TIMES_CONTACTED = 0
LAST_TIME_CONTACTED = 0
STARRED = 0
CUSTOM_RINGTONE = null
SEND_TO_VOICEMAIL = 0
CONTACT_PRESENCE = null
CONTACT_STATUS = null
CONTACT_STATUS_TIMESTAMP = null
CONTACT_STATUS_RES_PACKAGE = null
CONTACT_STATUS_LABEL = null
CONTACT_STATUS_ICON = null
_ID = 3098
LOOKUP_KEY = 298i1
DISPLAY_NAME = Mailbox abhören
DISPLAY_NAME_PRIMARY = Mailbox abhören
PHOTO_ID = null
PHOTO_URI = null
PHOTO_THUMBNAIL_URI = null
IN_VISIBLE_GROUP = 1
HAS_PHONE_NUMBER = 1
TIMES_CONTACTED = 0
LAST_TIME_CONTACTED = 0
STARRED = 0
CUSTOM_RINGTONE = null
SEND_TO_VOICEMAIL = 0
CONTACT_PRESENCE = null
CONTACT_STATUS = null
CONTACT_STATUS_TIMESTAMP = null
CONTACT_STATUS_RES_PACKAGE = null
CONTACT_STATUS_LABEL = null
CONTACT_STATUS_ICON = null
However, in the ContactsContract.Data, the entries for these two contacts are completely irrelevant and point to some other contact (real names and addresses obfuscated, dumped using http://tny.cz/afef6836):
Code:
id = 6985
mimeType = vnd.android.cursor.item/photo
rawContactId = 1087
isPrimary = 0
isSuperPrimary = 0
dataVersion = 0
data1 = null
data2 = null
data3 = null
data4 = null
data5 = null
data6 = null
data7 = null
data8 = null
data9 = null
data10 = null
data11 = null
data12 = null
data13 = null
data14 = null
data15 = null
sync1 = https://www.google.com/m8/feeds/photos/media/[email protected]/zzz
sync2 = null
sync3 = null
sync4 = 0
id = 6986
mimeType = vnd.android.cursor.item/name
rawContactId = 1087
isPrimary = 0
isSuperPrimary = 0
dataVersion = 1
data1 = Someone Private
data2 = Someone
data3 = Private
data4 = null
data5 = null
data6 = null
data7 = null
data8 = null
data9 = null
data10 = 1
data11 = 0
data12 = null
data13 = null
data14 = null
data15 = null
sync1 = null
sync2 = null
sync3 = null
sync4 = 11
id = 6987
mimeType = vnd.android.cursor.item/note
rawContactId = 1087
isPrimary = 0
isSuperPrimary = 0
dataVersion = 1
data1 =
data2 = null
data3 = null
data4 = null
data5 = null
data6 = null
data7 = null
data8 = null
data9 = null
data10 = null
data11 = null
data12 = null
data13 = null
data14 = null
data15 = null
sync1 = null
sync2 = null
sync3 = null
sync4 = 11
id = 6988
mimeType = vnd.android.cursor.item/nickname
rawContactId = 1087
isPrimary = 0
isSuperPrimary = 0
dataVersion = 1
data1 = null
data2 = null
data3 = null
data4 = null
data5 = null
data6 = null
data7 = null
data8 = null
data9 = null
data10 = null
data11 = null
data12 = null
data13 = null
data14 = null
data15 = null
sync1 = null
sync2 = null
sync3 = null
sync4 = 11
id = 6989
mimeType = vnd.com.google.cursor.item/contact_misc
rawContactId = 1087
isPrimary = 0
isSuperPrimary = 0
dataVersion = 1
data1 = null
data2 = null
data3 = null
data4 = null
data5 = null
data6 = null
data7 = null
data8 = 4
data9 = 5
data10 = null
data11 = null
data12 = null
data13 = null
data14 = null
data15 = null
sync1 = null
sync2 = null
sync3 = null
sync4 = 11
id = 6990
mimeType = vnd.android.cursor.item/group_membership
rawContactId = 1087
isPrimary = 0
isSuperPrimary = 0
dataVersion = 1
data1 = 5
data2 = null
data3 = null
data4 = null
data5 = null
data6 = null
data7 = null
data8 = null
data9 = null
data10 = null
data11 = null
data12 = null
data13 = null
data14 = null
data15 = null
sync1 = null
sync2 = null
sync3 = null
sync4 = 11
id = 6991
mimeType = vnd.android.cursor.item/phone_v2
rawContactId = 1087
isPrimary = 0
isSuperPrimary = 0
dataVersion = 1
data1 = +380975356308
data2 = 2
data3 = null
data4 = +380975356308
data5 = null
data6 = null
data7 = null
data8 = null
data9 = null
data10 = null
data11 = null
data12 = null
data13 = null
data14 = null
data15 = null
sync1 = null
sync2 = null
sync3 = null
sync4 = 11
id = 2340183
mimeType = vnd.android.cursor.item/name_svoice_dmetaphone_primary_encoding
rawContactId = 1087
isPrimary = 0
isSuperPrimary = 0
dataVersion = 0
data1 = SOMEONE PRIVATE
data2 = SOMEONE
data3 = PRIVATE
data4 = null
data5 = null
data6 = null
data7 = null
data8 = null
data9 = null
data10 = null
data11 = null
data12 = null
data13 = null
data14 = null
data15 = null
sync1 = null
sync2 = null
sync3 = null
sync4 = null
I've also tried dumping the whole ContactsContract.Data database and found entries with the expected number:
Code:
id = 118113
mimeType = vnd.android.cursor.item/phone_v2
rawContactId = 3047
isPrimary = 1
isSuperPrimary = 0
dataVersion = 1
data1 = +491793000333
data2 = 2
data3 = null
data4 = +491793000333
data5 = null
data6 = null
data7 = null
data8 = null
data9 = null
data10 = null
data11 = null
data12 = null
data13 = null
data14 = null
data15 = null
sync1 = null
sync2 = null
sync3 = null
sync4 = null
id = 6969
mimeType = vnd.android.cursor.item/phone_v2
rawContactId = 1084
isPrimary = 0
isSuperPrimary = 0
dataVersion = 1
data1 = +491793000333
data2 = 2
data3 = null
data4 = +491793000333
data5 = null
data6 = null
data7 = null
data8 = null
data9 = null
data10 = null
data11 = null
data12 = null
data13 = null
data14 = null
data15 = null
sync1 = null
sync2 = null
sync3 = null
sync4 = 11
3047 does not exist. 1084 points closes the loop and points to the Someone Private:
Code:
_ID = 1084
LOOKUP_KEY = 4063i2a66cd210fc7ef2a
DISPLAY_NAME = Someone Private
DISPLAY_NAME_PRIMARY = Someone Private
PHOTO_ID = null
PHOTO_URI = null
PHOTO_THUMBNAIL_URI = null
IN_VISIBLE_GROUP = 1
HAS_PHONE_NUMBER = 1
TIMES_CONTACTED = 0
LAST_TIME_CONTACTED = 0
STARRED = 0
CUSTOM_RINGTONE = null
SEND_TO_VOICEMAIL = 0
CONTACT_PRESENCE = null
CONTACT_STATUS = null
CONTACT_STATUS_TIMESTAMP = null
CONTACT_STATUS_RES_PACKAGE = null
CONTACT_STATUS_LABEL = null
CONTACT_STATUS_ICON = null
I am confused. Is this some non-standard database used only by Samsung? My phone seems to work just fine with my voicemail and never calls Someone Private when I dial it. And when I dial Someone Private's number it is never identified as "Mailbox abhören".

Related

[Q] Working with simple XML array

Not sure why it crash while looping the array:
Code:
final String tname[] = getResources().getStringArray(R.array.tname);
final int tid[] = getResources().getIntArray(R.array.tid);
final int tlv[] = getResources().getIntArray(R.array.tlv);
int tlength = tname.length;
String pname[] = new String[tlength];
int pid[] = new int[tlength];
for(int i = 0; i < tlength; i++) {
if(tlv[i] <= 0) {
pname[i] = tname[i];
pid[i] = tid[i];
}
}
setListAdapter(new ArrayAdapter<String>(this, R.layout.pMenu, pname));
Thanks in advance!

[Q] how to restore a deleted application without the usb debug ?

My question is very simple and hopefully the great teachers in this forum can answer.
how to go and change the file in system / build.prop without activating usb debuging?
how to restore all my apps in / system / which have been erased without activating usb debuging?
<< ycusoy | http://admin-belajar.blogspot.com >>
Bonus: text mouse rotate
Code:
<style type="text/css">
/* Circle Text Styles */
#outerCircleText {
/* Optional - DO NOT SET FONT-SIZE HERE, SET IT IN THE SCRIPT */
font-style: italic;font-weight: bold;font-family: 'comic sans ms', verdana, arial;color: #000;
/* End Optional *//* Start Required - Do Not Edit*/
position: absolute;top: 0;left: 0;z-index: 3000;cursor: default;}#outerCircleText div {position: relative;}#outerCircleText div div {position: absolute;top: 0;left: 0;text-align: center;}
/* End Required *//* End Circle Text Styles */
</style>
<script type="text/javascript">
;(function(){ // Your message here (QUOTED STRING)
var msg = "http://forum.xda-developers.com/editpost.php?do=editpost&postid=26043694";
/* THE REST OF THE EDITABLE VALUES BELOW ARE ALL UNQUOTED NUMBERS */// Set font's style size for calculating dimensions// Set to number of desired pixels font size (decimal and negative numbers not allowed)
var size = 14;
// Set both to 1 for plain circle, set one of them to 2 for oval// Other numbers & decimals canhave interesting effects, keep these low (0 to 3)
var circleY = 0.75; var circleX = 2;
// The larger this divisor, the smaller the spaces between letters// (decimals allowed, not negative numbers)
var letter_spacing = 5;
// The larger this multiplier, the bigger the circle/oval// (decimals allowed, not negative numbers, some rounding is applied)
var diameter = 10; // Rotation speed, set it negative if you want it to spin clockwise (decimals allowed)
var rotation = 0.4; // This is not the rotation speed,its the reaction speed, keep low!// Set this to 1 or a decimal less than one (decimals allowed, not negative numbers)
var speed = 0.3;
////////////////////// Stop Editing //////////////////////
if (!window.addEventListener &&!window.attachEvent ||!document.createElement) return;msg = msg.split('');var n = msg.length - 1, a = Math.round(size * diameter * 0.208333), currStep = 20,ymouse = a * circleY + 20, xmouse = a * circleX + 20, y = [], x = [], Y = [], X = [],o = document.createElement('div'), oi= document.createElement('div'),b = document.compatMode && document.compatMode !="BackCompat"? document.documentElement : document.body,mouse = function(e){e = e || window.event;ymouse = !isNaN(e.pageY)? e.pageY : e.clientY;
//
y-positionxmouse = !isNaN(e.pageX)? e.pageX : e.clientX;
//
x-position},makecircle = function(){
// rotation/positioning
if(init.nopy){ o.style.top = (b || document.body).scrollTop + 'px'; o.style.left = (b || document.body).scrollLeft + 'px';};currStep -= rotation;for (var d, i = n; i > -1; --i){
// makes the circle
d = document.getElementById('iemsg'+ i).style; d.top = Math.round(y[i] + a * Math.sin((currStep + i) / letter_spacing) * circleY - 15) + 'px'; d.left = Math.round(x[i] + a * Math.cos((currStep + i) / letter_spacing) * circleX) + 'px';};},drag = function(){
// makes the resistancey
[0] = Y[0] += (ymouse - Y[0]) * speed;x[0] = X[0] += (xmouse - 20 - X[0]) * speed;for (var i = n; i > 0; --i){ y[i] = Y[i] += (y[i-1] - Y[i]) * speed; x[i] = X[i] += (x[i-1] - X[i]) * speed;};makecircle();},init = function(){
// appends message divs, & sets initial values for positioning arrays
if(!isNaN(window.pageYOffset)){ ymouse += window.pageYOffset; xmouse += window.pageXOffset;} else init.nopy = true;for (var d, i = n; i > -1; --i){ d = document.createElement('div'); d.id = 'iemsg' + i; d.style.height = d.style.width = a+ 'px'; d.appendChild(document.createTextNode(msg[i])); oi.appendChild(d); y[i] = x[i] = Y[i]= X[i] = 0;};o.appendChild(oi); document.body.appendChild(o);setInterval(drag, 25);},ascroll = function(){ymouse += window.pageYOffset;xmouse += window.pageXOffset;window.removeEventListener('scroll', ascroll, false);};o.id = 'outerCircleText'; o.style.fontSize = size + 'px';if (window.addEventListener){window.addEventListener('load', init, false);document.addEventListener('mouseover', mouse, false);document.addEventListener('mousemove', mouse, false); if (/Apple/.test(navigator.vendor)) window.addEventListener('scroll', ascroll, false);}else if (window.attachEvent){window.attachEvent('onload', init);document.attachEvent('onmousemove', mouse);};})();</script>
paste before closing tag </head>

[Q]How can I merege two *.wav files?

I looked all over the net and I couldn't find something that works.
First there is this:
Code:
File wave1 = new File(wavFile1);
if(!wave1.exists())
throw new Exception(wave1.getPath() + " - File Not Found");
AudioInputStream clip1 = AudioSystem.getAudioInputStream(wave1);
AudioInputStream clip2 = AudioSystem.getAudioInputStream(new File(wavFile2));
AudioInputStream emptyClip =
AudioSystem.getAudioInputStream(new File(emptyWavPath));
AudioInputStream appendedFiles =
new AudioInputStream(
new SequenceInputStream(clip1, emptyClip),
clip1.getFormat(),
clip1.getFrameLength() + 100
);
clip1 = appendedFiles;
appendedFiles =
new AudioInputStream(
new SequenceInputStream(clip1, clip2),
clip1.getFormat(),
clip1.getFrameLength() + clip2.getFrameLength()
);
but android dosen't support java.sound.sampled
there is also this:
Code:
private void merge2WavFiles(String wavFile1, String wavFile2, String newWavFilePath) {
long RECORDER_SAMPLERATE = 44100;
long RECORDER_BPP = 16;
FileInputStream in1 = null, in2 = null;
FileOutputStream out = null;
long totalAudioLen = 0;
long totalDataLen = totalAudioLen + 36;
long longSampleRate = RECORDER_SAMPLERATE;
int channels = 2;
long byteRate = RECORDER_BPP * RECORDER_SAMPLERATE * channels / 8;
byte[] data = new byte[100];
try {
in1 = new FileInputStream(wavFile1);
in2 = new FileInputStream(wavFile2);
out = new FileOutputStream(newWavFilePath);
totalAudioLen = in1.getChannel().size() + in2.getChannel().size();
totalDataLen = totalAudioLen + 36;
WriteWaveFileHeader(out, totalAudioLen, totalDataLen, longSampleRate, channels, byteRate);
while (in1.read(data) != -1) {
out.write(data);
}
while (in2.read(data) != -1) {
out.write(data);
}
out.close();
in1.close();
in2.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
private void WriteWaveFileHeader(FileOutputStream out, long totalAudioLen,
long totalDataLen, long longSampleRate, int channels, long byteRate)
throws IOException {
byte[] header = new byte[44];
header[0] = 'R';
header[1] = 'I';
header[2] = 'F';
header[3] = 'F';
header[4] = (byte)(totalDataLen & 0xff);
header[5] = (byte)((totalDataLen >> 8) & 0xff);
header[6] = (byte)((totalDataLen >> 16) & 0xff);
header[7] = (byte)((totalDataLen >> 24) & 0xff);
header[8] = 'W';
header[9] = 'A';
header[10] = 'V';
header[11] = 'E';
header[12] = 'f';
header[13] = 'm';
header[14] = 't';
header[15] = ' ';
header[16] = 16;
header[17] = 0;
header[18] = 0;
header[19] = 0;
header[20] = 1;
header[21] = 0;
header[22] = (byte) channels;
header[23] = 0;
header[24] = (byte)(longSampleRate & 0xff);
header[25] = (byte)((longSampleRate >> 8) & 0xff);
header[26] = (byte)((longSampleRate >> 16) & 0xff);
header[27] = (byte)((longSampleRate >> 24) & 0xff);
header[28] = (byte)(byteRate & 0xff);
header[29] = (byte)((byteRate >> 8) & 0xff);
header[30] = (byte)((byteRate >> 16) & 0xff);
header[31] = (byte)((byteRate >> 24) & 0xff);
header[32] = (byte)(2 * 16 / 8);
header[33] = 0;
header[34] = 16;
header[35] = 0;
header[36] = 'd';
header[37] = 'a';
header[38] = 't';
header[39] = 'a';
header[40] = (byte)(totalAudioLen & 0xff);
header[41] = (byte)((totalAudioLen >> 8) & 0xff);
header[42] = (byte)((totalAudioLen >> 16) & 0xff);
header[43] = (byte)((totalAudioLen >> 24) & 0xff);
out.write(header, 0, 44);
}
but is also dosen't work.
In all cases the result sound file is empty without sound.
How can I merge two *.wav files?
I m also searching for months like MP3 EDITOR LIKE software..which can combine two or more sound file and make one..
But all apps i found is just mp3 cutter..
There is one app in symbian os my friend have in his c6
Which do editing i forgot the name but for sure in android i have not found one since six months
we all should be polite enough to press thanks for anyone who helped US.

Allwinner A23 Tablet: Launching Camera App freezes Tablet.

Hello i changed the Rom on my Tablet to :
PH_A76h_android4.4_v2.0_800x480-auto-gc2035-gc0308-wifi5990p-20141211a.img
Everything works okay, but not the Camera.
The Tablet has 2 Cameras Front and Back with 0,3 Mpixels each.
The are on the same Cable going from the Mainboard to the FrontCam and then to the Back Camera.
When i launch the App the Tablet freezes.. Sometimes it resets itself after an Minute or so (not always)
BTW:
I have saved the Data of the Nand-Partitions with the old Firmware (if you need some infos/settings/config from them)
I also have changed the script0.bin from the old Firmware to fex and changed everything in DragonFaces SystemConfiguration like it was in the Script0.bin from the original Firmware.
Here is the Block i Changed in System-Editor:
Code:
;--------------------------------------------------------------------------------
;vip (video input port) configuration
;vip_used: 0:disable 1:enable
;vip_mode: 0:sample one interface to one buffer 1:sample two interface to one buffer
;vip_dev_qty: The quantity of devices linked to capture bus
;vip_dev(x)_isp_used 0: not use isp 1:use isp
;vip_dev(x)_fmt: 0:yuv 1:bayer raw rgb
;vip_dev(x)_stby_mode: 0:not shut down power at standby 1:shut down power at standby
;vip_dev(x)_vflip: flip in vertical direction 0:disable 1:enable
;vip_dev(x)_hflip: flip in horizontal direction 0:disable 1:enable
;vip_dev(x)_iovdd: camera module io power handle string, pmu power supply
;vip_dev(x)_iovdd_vol: camera module io power voltage, pmu power supply
;vip_dev(x)_avdd: camera module analog power handle string, pmu power supply
;vip_dev(x)_avdd_vol: camera module analog power voltage, pmu power supply
;vip_dev(x)_dvdd: camera module core power handle string, pmu power supply
;vip_dev(x)_dvdd_vol: camera module core power voltage, pmu power supply
;vip_dev(x)_afvdd: camera module vcm power handle string, pmu power supply
;vip_dev(x)_afvdd_vol: camera module vcm power voltage, pmu power supply
;x indicates the index of the devices which are linked to the same capture bus
;fill voltage in uV, e.g. iovdd = 2.8V, vip_devx_iovdd_vol = 2800000
;fill handle string as below:
;axp22_eldo3
;axp22_dldo4
;axp22_eldo2
;fill handle string "" when not using any pmu power supply
;--------------------------------------------------------------------------------
[csi0]
vip_used = 1
vip_mode = 0
vip_dev_qty = 2
vip_csi_pck = port:PE00<2><default><default><default>
vip_csi_mck = port:PE01<2><default><default><default>
vip_csi_hsync = port:PE02<2><default><default><default>
vip_csi_vsync = port:PE03<2><default><default><default>
vip_csi_d0 = port:PE04<2><default><default><default>
vip_csi_d1 = port:PE05<2><default><default><default>
vip_csi_d2 = port:PE06<2><default><default><default>
vip_csi_d3 = port:PE07<2><default><default><default>
vip_csi_d4 = port:PE08<2><default><default><default>
vip_csi_d5 = port:PE09<2><default><default><default>
vip_csi_d6 = port:PE10<2><default><default><default>
vip_csi_d7 = port:PE11<2><default><default><default>
vip_dev0_mname = "siv121d"
vip_dev0_lane = 1
vip_dev0_twi_id = 2
vip_dev0_twi_addr = 102
vip_dev0_isp_used = 0
vip_dev0_fmt = 0
vip_dev0_stby_mode = 0
vip_dev0_vflip = 0
vip_dev0_hflip = 0
vip_dev0_iovdd = "axp22_dldo3"
vip_dev0_iovdd_vol = 2800000
vip_dev0_avdd = "axp22_ldoio0" vip_dev0_avdd_vol = 2800000
vip_dev0_dvdd = "axp22_eldo2" vip_dev0_dvdd_vol = 1800000
vip_dev0_afvdd = ""
vip_dev0_afvdd_vol = 2800000
vip_dev0_power_en =
vip_dev0_reset = port:PE14<1><default><default><0>
vip_dev0_pwdn = port:PE15<1><default><default><1>
vip_dev0_flash_en = port:PB00<1><default><default><0>
vip_dev0_flash_mode =
vip_dev0_af_pwdn =
vip_dev1_mname = "siv121d"
vip_dev1_lane = 1
vip_dev1_twi_id = 2
vip_dev1_twi_addr = 102
vip_dev1_isp_used = 0
vip_dev1_fmt = 0
vip_dev1_stby_mode = 0
vip_dev1_vflip = 0
vip_dev1_hflip = 0
vip_dev1_iovdd = "axp22_dldo3"
vip_dev1_iovdd_vol = 2800000
vip_dev1_avdd = "axp22_ldoio0"
vip_dev1_avdd_vol = 2800000
vip_dev1_dvdd = "axp22_eldo2"
vip_dev1_dvdd_vol = 1800000
vip_dev1_afvdd = ""
vip_dev1_afvdd_vol = 2800000
vip_dev1_power_en =
vip_dev1_reset = port:PE16<1><default><default><0>
vip_dev1_pwdn = port:PE17<1><default><default><1>
vip_dev1_flash_en = port:PB00<1><default><default><0>
vip_dev1_flash_mode =
vip_dev1_af_pwdn =
[camera_list_para]
camera_list_para_used = 0
ov7670 = 0
gc0308 = 1
gt2005 = 0
hi704 = 0
sp0838 = 0
mt9m112 = 0
mt9m113 = 0
gc2035 = 1
ov2655 = 0
hi253 = 1
gc0307 = 0
mt9d112 = 0
ov5640 = 0
ov5647 = 0
gc2015 = 0
ov2643 = 0
gc0329 = 0
gc0309 = 0
s5k4ec = 0
siv121d = 0
siv120d = 0
I also copied camera.cfg from the old /system/etc to the new installation.
But still freezes don't know what to do now.
Please help.

Video Encryption Decryption takes too much time

This is code for encryption of video
FileInputStream fis = new FileInputStream(extStore+"/digilearn/try.mp4");
FileOutputStream fos = new FileOutputStream(extStore+"/digilearn/enctry.mp4");
SecretKeySpec sks = new SecretKeySpec("MyDifficultPassw".getBytes(),
"AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, sks);
CipherOutputStream cos = new CipherOutputStream(fos, cipher);
int b;
byte[] d = new byte[8192];
while ((b = fis.read(d)) != -1) {
cos.write(d, 0, b);
}
// Flush and close streams.
cos.flush();
cos.close();
fis.close();
This is the code for decryption of video
File extStore = Environment.getExternalStorageDirectory();
FileInputStream fis = new FileInputStream(extStore+"/digilearn/enctry.mp4");
FileOutputStream fos = new FileOutputStream(extStore+"/digilearn/dectry.mp4");
SecretKeySpec sks = new SecretKeySpec("MyDifficultPassw".getBytes(),
"AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, sks);
CipherInputStream cis = new CipherInputStream(fis, cipher);
int b;
byte[] d = new byte[2*8192];
while ((b = cis.read(d)) != -1) {
fos.write(d, 0, b);
}
fos.flush();
fos.close();
cis.close();
with above code encryption and decryption both works but it take too much time when encrypted video file from sd card with video size is 1 GB.

Categories

Resources