How do I get the string array from a Notification bundle? - android

I have an app that reads notifications to the driver while driving. I am trying to parse the various notifications. Those that use the old 'tickerText' work fine but several apps like Skype don't support that. Instead, the text in the notification after the first message just says something like "3 new messages". Not very helpful. I want the last message string instead. I wrote this:
public class Catcher extends NotificationListenerService {
File file;
String dir;
File save;
int count = 0;
#Override
public void onCreate() {
super.onCreate();
dir = Environment.getExternalStorageDirectory() + "/NotCatch";
save = new File(dir);
if(!save.exists()){
save.mkdirs();
}
//Toast.makeText(this, dir + " " + file.getName(), Toast.LENGTH_LONG).show();
}
#Override
public void onNotificationPosted(StatusBarNotification sbn) {
super.onNotificationPosted(sbn);
file = new File(save, "NotCatch" + count + ".txt");
count++;
String temp = "";
String[] lines;
Notification not = sbn.getNotification();
temp += "Category: " + not.category+ "\n";
temp+= "TickerText: " + not.tickerText + "\n";
temp += "Extras..."+ "\n";
Bundle bun = not.extras;
temp+= "BigText: " + bun.getString(Notification.EXTRA_BIG_TEXT)+ "\n";
temp+= "SummaryText: " + bun.getString(Notification.EXTRA_SUMMARY_TEXT)+ "\n";
temp+= "InfoText: " + bun.getString(Notification.EXTRA_INFO_TEXT)+ "\n";
temp+= "Text: " + bun.getString(Notification.EXTRA_TEXT)+ "\n";
temp+= "TextLines: " + bun.getString(Notification.EXTRA_TEXT_LINES)+ "\n";
temp+= "SubText: " + bun.getString(Notification.EXTRA_SUB_TEXT) + "\n";
temp+= "Title:" + bun.getString(Notification.EXTRA_TITLE) +"\n";
temp+= "Big Title:" + bun.getString(Notification.EXTRA_TITLE_BIG) +"\n";
/* lines = bun.getString(Notification.EXTRA_TEXT_LINES).split("\n");
temp += "Lines... \n" ;
int cnt = 0;
for (String line : lines) {
temp+= cnt + ": " + line + "\n";
cnt++;
}*/
Looper.prepare();
try {
FileOutputStream fos = new FileOutputStream(file);
fos.write(temp.getBytes());
fos.close();
Toast.makeText(this,"File written", Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
}
This is just what I have so far for testing of course. I can get the bundle from the notification but it can't get the string array of the message lines. It looks like this in the debugger. 'bun' below is the 'Bundle' from the 'Notification'.
My question is this. How do I get the array of strings that start with "some message text - 4"? This is the bundle from an Android Notification.

I finally was able to get the strings this way
CharSequence[] lines = bun.getCharSequenceArray(Notification.EXTRA_TEXT_LINES);
for(CharSequence line : lines){
temp+= "line: " + line.toString() + "\n";
}

Since the strings you are trying to retrieve are contained in the ArrayMap mMap (according to the debugger image), and as implementations of Map are serializable, you'll want to do the following to first retrieve that map:
ArrayMap map = bun.getSerializableExtra("mMap");
Then, you should be able to get the array of strings you want (which according to the debugger image is an array of CharSequence objects) with the following:
CharSequence[] messages = (CharSequence[]) map.valueAt(1);
An interesting read on bundles and maps:
https://medium.com/the-wtf-files/the-mysterious-case-of-the-bundle-and-the-map-7b15279a794e#.kf3m2haa3

Related

Failed to publish message on mqtt broker

I am developing a mobile application that need to implement mqtt. I need to publish the data to the mqtt broker, but it always fail to be published when i try to publish the image data which is the byte array of the image.
It didn't show any error when publish, but it did not published any data on the broker when I try to publish the message. The message can only be published when image data is removed from the payload which is the pichex.
Each data published on the mqtt broker need to be converted into hex ascii code. The byte array of image also need to be converted into hex ascii string code before publish to the broker as it is the requirement of the project.
private void publish(){
String command = "000000";
String reserve = "303030303030303030303030303030303030303030303030";
String tag = "tag";
name = eTname.getText().toString();
price = eTprice.getText().toString();
type = TypeS.getSelectedItem().toString();
desc = eTdesc.getText().toString();
userid = MainActivity.getGetuserid();
String namehex = toHexString(name);
String pricehex = toHexString(price);
String typehex = toHexString(type);
String deschex = toHexString(desc);
String useridhex = toHexString(userid);
Bitmap PicBitmap = ((BitmapDrawable)iVpic.getDrawable()).getBitmap();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PicBitmap.compress(Bitmap.CompressFormat.PNG, 100, bos);
byte[] picbyte = bos.toByteArray();
String pichex = bytesToHex(picbyte);
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss");
Date currentTime = Calendar.getInstance().getTime();
String currentTimeString = df.format(currentTime);
String payload = "{command:" + command + ", reserve:" + reserve + ", Client ID:" + serverConnectTo + ", Posted name:" + namehex +
", Posted Price:" + pricehex + ", Posted Type:" + typehex + ", Posted Description:" + deschex
+ ", Posted Picture:" + pichex + ", Date Time Posted:" + currentTimeString + ", User ID:" + useridhex + "}";
byte[] encodedPayload = new byte[0];
try {
encodedPayload = payload.getBytes();
MqttMessage message = new MqttMessage(encodedPayload);
message.setQos(qos);
mqttClient.publish(topic, message);
} catch (MqttException e) {
e.printStackTrace();
}
}
public static String toHexString(String input) {
return String.format("%x", new BigInteger(1, input.getBytes()));
}
public static String bytesToHex(byte[] in) {
final StringBuilder builder = new StringBuilder();
for(byte b : in) {
builder.append(String.format("%02x", b));
}
return builder.toString();
}
The hex string value of the picture that need to be published is:
89504e470d0a1a0a0000000d49484452000005dc0000046508020000002ce5923a0000000373424954080808dbe14fe00000200049444154789cecbd617723c971b41b91550dcecaf6bde7feff3ff99ed7d60e89ae8cb81fb21a046738eb5dd9d648de7c3ca74d8140a3d16842aa4064046da3699aa6699aa6699aa6699aa6f9fb123ffb009aa6699aa6699aa6699aa669fe8cb428d3344dd3344dd3344dd3344df3136851a6699aa6699aa6699aa6699ae627d0a24cd3344dd3344dd3344dd334cd4fa04599a6699aa6699aa6699aa6699a9f408b324dd3344dd3344dd3344dd3343f8116659aa6699aa6699aa6699aa6697e022dca344dd3344dd3344dd3344dd3fc045a94699aa6699aa6699aa6699aa6f909b428d3344dd3344dd3344dd3344df3136851a6699aa6699aa6699aa6699ae627d0a24cd3344dd3344dd3344dd334cd4fa04599a6699aa6699aa6699aa6699a9f408b324dd3344dd3344dd3344dd3343f8116659aa6699aa6699aa6699aa6697e022dca344dd3344dd3344dd3344dd3fc045a94699aa6699aa6699aa6699aa6f909b428d3344dd3344dd3344dd3344df3136851a6699aa6699aa6699aa6699ae627d0a24cd3344dd3344dd3344dd334cd4fa04599a6699aa6699aa6699aa6699a9f408b324dd3344dd3344dd3344dd3343f8116659aa6699aa6699aa6699aa6697e022dca344dd3344dd3344dd3344dd3fc045a94699aa6699aa6699aa6699aa6f909b428d3344dd3344dd3344dd3344df3136851a6699aa6699aa6699aa6699ae627d0a24cd3344dd3344dd3344dd334cd4fa04599a6699aa6699aa6699aa6699a9f408b324dd3344dd3344dd3344dd3343f8116659aa6699aa6699aa6699aa6697e022dca344dd3344dd3344dd3344dd3fc045a94699aa6699aa6699aa6699aa6f909b428d3344dd3344dd3344dd3344df3136851a6699aa6699aa6699aa6699ae627d0a24cd3344dd3344dd3344dd334cd4fa04599a6699aa6699aa6699aa6699a9f408b324dd3344dd3344dd3344dd3343f8116659aa6699aa6699aa6699aa6697e02f3671f40d3344dd334efd8fef476927fe723699aa6699aa669fea769a74cd3344dd3344dd3344dd334cd4fa04599a6699aa6699aa6699aa6699a9f007f64936e9aa6699ae6bfceffd6ff9eed71aaa6699aa6699aff3aed94699aa6699aa6699aa6699aa6f90974d06fd3344dd3fc0ff2479d323f72a0fcb3386eda41d3344dd3344df3fb69a74cd3344dd3344dd3344dd334cd4fa09d324dd334cd3f0e02e2f76dffd1d00f6eff8d4315003300c00100140d00bcf656de1813340002a0f77fbcb6a2c3fce4fcf0a3b1c6bfcbbff2cd7eb09ff53b0c00e3e36dff2c0699c73bf5d3afa2ffeaf56c80bf7bfb47f967793b9ba6699ae69f9d16659aa6699a7f08840404f8f76d11df8a028f1d95b0f1ad4a221b1f876bc881f7b1a06f17a13f9ac29116be1fd2a1ae95efd3fe4100b157dcdf2cbc251880616094624204692851a7822421844192b4e120609990ec12659c701808d2e400b49f58d8c7493e6b460fa1e71b02248c0fff0000593bfab0ae37c8083fbda8c770d5b75356b46d40833f941e6c5fe7874f0fff5ce7fad178d456b21c00fce15dae03defb34b27efa8342c88feffefb658f6faf493d6d7fdf113d092d3244c477dbf10321f38f427faecbf4745ad3344dd3fcf7d2a24cd3344df30f857edff68faca9fd2e95d87eacea9f7ffee4417e3cf8039f3c84c256165442cfd32373bb60b616f05826bb9ec11fc50e1ab400818265c4a5cb2004386107606400b658af2261264823499a2aed263c002088787f9eefe598ebf4d01f45193e8e09803faceb83012760204a5279fc3ee2c9cb53f7787e033e39cf7efaf947f7fa6fe1f1127eeb78fe30bcb67fece0bfbfaa8bdff4ce3c2ee33ff4547f137c1719bf77de344dd3344df3df468b324dd334cd3f0e7f406a11fcae1becdb1ede930f8e8beb37d7ddf97cf3e507f86e99cb3fb8f265d9771e5acef5033fc82e4f7e1f8b60c0861d0410cfde0463ab29306cc35652a8bb03591a90edeb1cc80049030eda41879d00288204b7c981e5d7783a09fbac6c4bcf77ee0a7d761e9c008cbc5e65c0b1c7a6f6d68008d4d604307ec3b4719d2e3f7efe1b0383b71b259e5ed96ff007aeb73ae1df8b26efc7c9efefffed2e9eee5f7b90afcb8cef27fac329faccb0c2ba3900e2fb2d3fbdfd37f9d64f435c7f5d0e501fb6faee96921da3c59aa6699aa6f95b6851a6699aa6f987803f5842fb7371247e674acab593a79f7fd320f37b77e86fa496bde4f677a2ccb5d6fd60a588e774182cba06a904972d0690418009b0e68a980b166c486599b10540a897a3c7cb34610719b1a36a68925b9121be1365ea883476bacd9553b32d323f3c57ba13a083e425338579e5e3f83a1ebbb4a2271bcea767d2d710d3b61d919fff4f941fb7503d396ef0dff0167f47d997f0b40d50f68f148fff5cf1f19308755dcef9b4c565aafab85b1a105d7a5b001fb6c02004c4c7ed374ffc24a93c5edd472ebd53bf77fba371c2a6699aa6697e9316659aa6699a7f107eb488fdcf1d2b359cb3e76cfce497f96617bf31b8c4672fcdfb7e2ebe5db2fa7dd90c97c5410abc4b3397b1e2c10727821e712c1610e6b96f96390c0b346c7098212060e55bd8b56b695d4f7165a9ec85f17ed5368023af27211911d8f932789c193dfb6554d136212a1c8f8c924fd40d07a859278db1137e38f6e9535624f1f5300134e23de7e69b9dbdcf8925ec876664e71f0c
This is the image that need to publish
The size of the picture is about 100KB.
The message can be published only when the image data is removed from the payload which is the pichex:
String payload = "{command:" + command + ", reserve:" + reserve + ", Client ID:" + serverConnectTo + ", Posted name:" + namehex + ", Posted Price:" + pricehex + ", Posted Type:" + typehex + ", Posted Description:" + deschex + ", Date Time Posted:" + currentTimeString + ", User ID:" + useridhex + "}";
The message can be received by subscriber if pichex is removed:
{command:000000, reserve:303030303030303030303030303030303030303030303030, Client ID:Server, Posted name:627572676572, Posted Price:392e3939, Posted Type:6e6f6f646c65, Posted Description:616a6468, Date Time Posted:2018-10-14 08.09.29, User ID:696b6f6d61}

Save LogCat entries in SQLite-Database

Is it possible to save a logcat entry in a sqlite database?
If a user got an error I want to read the logs without having the phone connected to adb.
This is how I write logs: Log.d(TAG, "An error occured", e)
Thanks
Creating a log file will be better option to read error
public void mlogFile(String pActivityName, String pOperation, String pData) {
File lLogFilePath, lLogFile;
Date lDate;
CharSequence lCurrfolder;
FileWriter lFileWriter;
BufferedWriter lBuffWriter;
String lActivity, lOperation;
try {
lDate = new Date();
lCurrfolder = DateFormat.format("yyyyMMdd", lDate.getTime());
lLogFilePath = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "CSPDCLData/" + lCurrfolder + "/");
if (!lLogFilePath.exists()) {
lLogFilePath.mkdirs();
}
lLogFile = new File(lLogFilePath, "ADDLogfile.txt");
lFileWriter = new FileWriter(lLogFile, true);
lBuffWriter = new BufferedWriter(lFileWriter);
lActivity = pActivityName.length() != 0 ? ADDPadding(pActivityName, 25, ' ', 'L') + "~ " : "";
lOperation = pOperation.length() != 0 ? " : " + pData : "";
lBuffWriter.append(DateFormat.format("kk:mm:ss", lDate.getTime()) + " " + lActivity + pOperation + lOperation + "\n");
lBuffWriter.flush();
lBuffWriter.close();
lFileWriter.close();
} catch (IOException ex) {
Toast.makeText(this, "ERROR: " + ex.getMessage(), Toast.LENGTH_SHORT).show();
}
}
And at the time of error add this line
logFile(getClass().getSimpleName(),"methodName()", "An error occured"+ e.getMessage());

How to Extract Name,Phone Number and Email Address From Vision OCR result text in Android?

Here is my sample code where i want to get details...
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PHOTO_REQUEST && resultCode == RESULT_OK) {
launchMediaScanIntent();
try {
Bitmap bitmap = decodeBitmapUri(this, imageUri);
if (detector.isOperational() && bitmap != null) {
Frame frame = new Frame.Builder().setBitmap(bitmap).build();
SparseArray<TextBlock> textBlocks = detector.detect(frame);
String blocks = "";
String lines = "";
String words = "";
for (int index = 0; index < textBlocks.size(); index++) {
//extract scanned text blocks here
TextBlock tBlock = textBlocks.valueAt(index);
blocks = blocks + tBlock.getValue() + "\n" + "\n";
for (Text line : tBlock.getComponents()) {
//extract scanned text lines here
lines = lines + line.getValue() + "\n";
for (Text element : line.getComponents()) {
//extract scanned text words here
words = words + element.getValue() + ", ";
}
}
}
if (textBlocks.size() == 0) {
scanResults.setText("Scan Failed: Found nothing to scan");
} else {
scanResults.setText(scanResults.getText() + "Blocks: " + "\n");
scanResults.setText(scanResults.getText() + blocks + "\n");
scanResults.setText(scanResults.getText() + "---------" + "\n");
scanResults.setText(scanResults.getText() + "Lines: " + "\n");
scanResults.setText(scanResults.getText() + lines + "\n");
scanResults.setText(scanResults.getText() + "---------" + "\n");
scanResults.setText(scanResults.getText() + "Words: " + "\n");
scanResults.setText(scanResults.getText() + words + "\n");
scanResults.setText(scanResults.getText() + "---------" + "\n");
}
} else {
scanResults.setText("Could not set up the detector!");
}
} catch (Exception e) {
Toast.makeText(this, "Failed to load Image", Toast.LENGTH_SHORT).show();
Log.e(LOG_TAG, e.toString());
}
}
}
You have nice libraries to parse link (emails,websites etc) like org.nibor.autolink
Concerning numbers you can have a look to libphonenumber. It is proposed by google and used by android. If you provide the country it can parse for you any format of the number.
Concerning names it is difficult. If you are using your app only for a country you can create a database with the names (in france we have a file in opendata proposed by a public servive) but it won't be complete...

Android get gmail email subject from notification

i would like to read the subject of a new received email (gmail) from an android notification.
I think i have to use a NotificationListenerService running in background, catch the notification of new email in real time, and read the subject from that.
But how can i read the subject or a part of body text? Is it possible?
Thank you very much.
Here is an example that catches notifications and puts them into a text file. I only made this for development purposes so I could see how each app populates the notifications but it should show you how to do it.
#Override
public void onNotificationPosted(StatusBarNotification sbn) {
super.onNotificationPosted(sbn);
new Store().execute(sbn);
}
private class Store extends AsyncTask<StatusBarNotification, Integer, Long> {
#Override
protected Long doInBackground(StatusBarNotification... params) {
String temp = "";
StatusBarNotification sbn = params[0];
Notification not = sbn.getNotification();
String pack = sbn.getPackageName();
// dump all the android notifications
if (pack.startsWith("com.android")) return null;
if (pack.startsWith("com.estrongs")) return null;
if (pack.startsWith("com.motorola")) return null;
count++;
if (not.category != null)
temp += "Category: " + not.category.toString() + "\n";
else
temp += "Category = null \n";
if (not.tickerText != null)
temp += "TickerText: " + not.tickerText.toString() + "\n";
else
temp += "TickerText = null \n";
temp += "Key: " + sbn.getKey() + "\n" + "ID: " + sbn.getId() + "\n";
SimpleDateFormat format = new SimpleDateFormat("DD-kk:mm:ss:SSS");
Long ptime = sbn.getPostTime();
temp += "Post time: " + format.format(ptime) + "\n";
Long nottime = not.when;
temp += "When: " + format.format(nottime) + "\n";
temp += "Extras..." + "\n";
Bundle bun = not.extras;
if (bun.getString(Notification.EXTRA_BIG_TEXT) != null)
temp += "BigText: " + bun.getString(Notification.EXTRA_BIG_TEXT).toString() + "\n";
else
temp += "BigText = null \n";
if (bun.getString(Notification.EXTRA_SUMMARY_TEXT) != null)
temp += "SummaryText: " + bun.getString(Notification.EXTRA_SUMMARY_TEXT).toString() + "\n";
else
temp += "SummaryText = null \n";
if (bun.getString(Notification.EXTRA_INFO_TEXT) != null)
temp += "InfoText: " + bun.getString(Notification.EXTRA_INFO_TEXT).toString() + "\n";
else
temp += "InfoText = null \n";
if (bun.getString(Notification.EXTRA_TEXT) != null)
temp += "Text: " + bun.getString(Notification.EXTRA_TEXT).toString() + "\n";
else
temp += "Text = null \n";
if (bun.getString(Notification.EXTRA_SUB_TEXT) != null)
temp += "SubText: " + bun.getString(Notification.EXTRA_SUB_TEXT).toString() + "\n";
else
temp += "SubText = null \n";
if (bun.getString(Notification.EXTRA_TITLE) != null)
temp += "Title:" + bun.getString(Notification.EXTRA_TITLE).toString() + "\n";
else
temp += "Title = null \n";
if (bun.getString(Notification.EXTRA_TITLE_BIG) != null)
temp += "Big Title:" + bun.getString(Notification.EXTRA_TITLE_BIG).toString() + "\n";
else
temp += "Big Title = null \n";
temp += "Fields... \n";
CharSequence[] lines = bun.getCharSequenceArray(Notification.EXTRA_TEXT_LINES);
if (lines != null) {
for (CharSequence line : lines) {
temp += "line: " + line.toString() + " \n";
}
} else {
temp += " no lines... \n";
}
file = new File(save, pack + count + ".txt");
try {
FileOutputStream fos = new FileOutputStream(file);
fos.write(temp.getBytes());
fos.close();
//Toast.makeText(this, "File written", Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
//Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
//Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
}
return null;
}
}
Notice I send the SBN to a background thread. The listener does not like much of anything in its thread. Also, the listener can be tricky with the debugger. I found that you need to disable the app in Android settings -> Sound & Notification -> Notification Access before you update the app. Then you can re-enable it once a package update is installed.
Hope that helps.

Get repeated Entries for Some Items in DataBase!

I am working on an android application. In which i have slideShows. I am parsing these through an xml and after parsing them, saving in the SQLite DB. Majority of the slideshows are saved properly but, sometimes this happens that the slides are saved two times that is, every slide in the slideShow is saved two times obviously with different PK but same content. which should be avoided.
Partial code is here, where i am getting the slides and trying to store them in DB.
ArrayList<SlideShowItem> slideItems = null;
slideItems=Utils.database.getSlideItemOfUrl(Constants.StoriesTable,tempSlideShow.getFullStoryUrl().substring(0, index - 1), type);
if (slideItems == null) {
Log.d("store in DB: ", " when SlideItems == null ");
Log.d("SlideShow Title: ", tempSlideShow.getTitle());
Log.d("SlideShow pub Date: ", tempSlideShow.getPubDate());
slideItems = tempSlideShow.getSlideShow();
Utils.database.storeSlideItem(Constants.StoriesTable, myUrl,slideItems, type);
Utils.topStorySlidesArrayList = slideItems;
slideItems = null ;
} else {
Log.d("SlideShow Title: ", tempSlideShow.getTitle());
Utils.topStorySlidesArrayList = slideItems;
slideItems = null ;
}
and code of function storeSlideItem in DataBase is:
public synchronized void storeSlideItem(String tableName, String, url,ArrayList<SlideShowItem> list, String type) {
System.out.println("size of the Array list: " + list.size());
String newType = null;
if (type == null) {
newType = "List";
}else{
newType = type;
}
ArrayList<SlideShowItem> newList = new ArrayList<SlideShowItem>();
//newList = null;
Iterator<SlideShowItem> iterator = list.iterator();
while (iterator.hasNext())
{
SlideShowItem sSItem = iterator.next();
if(!newList.contains(sSItem))
{
newList.add(sSItem);
}
}
try {
for (int i = 0; i < newList.size(); i++) {
SlideShowItem item = newList.get(i);
String itemUrl = url + i;// Unique URL for the DB;
String imgString = null;
Log.e("Loop Counter", " time " + i);
Drawable drawable = item.getImage();
if (item.getBody() != null) {
item.setBody(item.getBody().replace('\'', '`'));
// replace as it create syntax error for storing data
}
if (item.getSubTitle() != null) {
item.setSubTitle(item.getSubTitle().replace('\'', '`'));
}
if (drawable != null) {
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] b = baos.toByteArray();
imgString = Base64.encodeBytes(b);
}
if (isOpen()) {
myDB.execSQL("INSERT INTO " + tableName + "(" + column[1] + "," + column[2] + "," + column[3] + "," + column[4] + "," + column[6]
+ "," + column[7] + ",type) VALUES('" + itemUrl + "','" + item.getSubTitle() + "','" + item.getBody() + "','"
+ item.getImagePath() + "','" + item.getIndex() + "','" + imgString + "','" + newType + "Slide')");
if (item.getBody() != null) {
item.setBody(item.getBody().replace('`', '\''));// " ' "
// replace as it create syntax error for storing data
}
if (item.getSubTitle() != null) {
item.setSubTitle(item.getSubTitle().replace('`', '\''));
}
if (tableName.equals(Constants.StoriesTable)) {
item.setItemId(getItemID(tableName, itemUrl));
Utils.hashListStoriesIds.put(itemUrl, item.getItemId());
if (imgString != null) {
Utils.hashListImages.put(item.getItemId(), new Boolean(true));
} else {
Utils.hashListImages.put(item.getItemId(), new Boolean(false));
}
}
}
}
} catch (Exception e) {
Log.e("Error", "Exception: storeSlideItem type " + e.toString());
} finally {
closeConnection();
}
}
Please tell me anything that can get me out of this irritating problem. Any help is appreciated.
in DB for duplication of slides the view is somewhat like:
1 abc USA 111
2 abc USA 111
and so on this was for one slide of a slideShow. if i have 3 slides in a slideshow, i'll get 6 entries in DB each slide being saved for two times.
Use HashSet instead of ArrayList

Categories

Resources