List of usage examples for java.lang Integer toString
@HotSpotIntrinsicCandidate public static String toString(int i)
From source file:Main.java
public static int loadInteger(String key, int defaultVal, SQLiteDatabase db) { int ret;/* w ww . j a v a 2 s .com*/ try { ret = Integer.parseInt(loadString(key, Integer.toString(defaultVal), db)); } catch (Exception ex) { ret = defaultVal; } return ret; }
From source file:Main.java
private static String dumpRow(Cursor c) { String result = "VALUES("; for (int pos = 0; pos < c.getColumnCount(); pos++) { switch (c.getType(pos)) { case Cursor.FIELD_TYPE_NULL: result += "null"; break; case Cursor.FIELD_TYPE_INTEGER: result += Integer.toString(c.getInt(pos)); break; case Cursor.FIELD_TYPE_FLOAT: result += Float.toString(c.getFloat(pos)); break; case Cursor.FIELD_TYPE_STRING: result += DatabaseUtils.sqlEscapeString(c.getString(pos)); break; case Cursor.FIELD_TYPE_BLOB: result += "X'"; for (byte b : c.getBlob(pos)) { result += String.format("%02X", b); }/* w ww. j av a2s .com*/ result += "'"; break; default: return "Invalid field type " + c.getType(pos) + " at position " + pos; } if (pos < c.getColumnCount() - 1) { result += ", "; } } return result + ")"; }
From source file:Main.java
public static void iapAddProduct(String name, int ID, int type) { name = name.toLowerCase();/*from ww w. j av a2 s . c o m*/ Log.w("IAB AddProduct", "Adding: " + name + " to ID: " + Integer.toString(ID)); if (ID < 0 || ID >= MAX_PRODUCTS) return; g_iPurchaseProductStates[ID] = 0; g_sPurchaseProductNames[ID] = name; g_iPurchaseProductTypes[ID] = type; Log.w("IAB AddProduct", "Added: " + name); if (ID + 1 > g_iNumProducts) g_iNumProducts = ID + 1; }
From source file:Main.java
public static String int2String(int i, int digits, boolean leadingZero) { StringBuilder s = new StringBuilder(digits); s.append(Integer.toString(i)); while (s.length() < digits) { s.insert(0, (leadingZero ? "0" : " ")); }/* w ww.j a va2 s. c om*/ return s.toString(); }
From source file:Main.java
public static String saveToInternalSorage(Bitmap bitmapImage, Context context, int ID, String directoryName) { ContextWrapper cw = new ContextWrapper(context); File directory = cw.getDir(directoryName, Context.MODE_PRIVATE); // path to /data/data/yourapp/app_data/imageDir File path = new File(directory, "mpp_profile_pic_" + Integer.toString(ID)); // Create imageDir FileOutputStream fos = null;//from ww w .j av a2s . c om try { fos = new FileOutputStream(path); bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos); // Use the compress method on the BitMap object to write image to the OutputStream fos.close(); } catch (Exception e) { e.printStackTrace(); } return directory.getAbsolutePath(); }
From source file:Main.java
/** * Add a child element, whose text contents are the given int value. * //from w w w .j av a 2 s. c o m * @param doc Document object, used to build new elements. * @param elem Element to append new child to. * @param childName Name of the new child element. * @param childText Text contents of the new child element. */ public static void addChildInt(Document doc, Element elem, String childName, int childValue) { addChildText(doc, elem, childName, Integer.toString(childValue)); }
From source file:andrew.addons.NextFile.java
public static String nextFile(String filename) { int a = 1;/*from w w w. java2s .c o m*/ File file = new File(filename); while (file.exists() || file.isFile()) { file = new File(FilenameUtils.removeExtension(filename) + "(" + Integer.toString(a) + ")." + FilenameUtils.getExtension(filename)); a++; } return file.getName(); }
From source file:Main.java
public static int getTrainingWordsSetting(Context context) { Context applicationContext = context.getApplicationContext(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(applicationContext); String count = preferences.getString(TRAINING_WORDS_COUNT, Integer.toString(TRAINING_VIEW_PAGER_COUNT)); try {//from w w w . j ava 2 s . co m return Integer.parseInt(count); } catch (NumberFormatException ex) { return TRAINING_VIEW_PAGER_COUNT; } }
From source file:Main.java
private static String makeTimeString(int value, int chars) { String s = Integer.toString(value); while (s.length() < chars) { s = "0" + s; }//from ww w . j av a 2 s .c om return s; }
From source file:Main.java
public static final void writeIntArrayXml(int[] val, String name, XmlSerializer out) throws XmlPullParserException, java.io.IOException { if (val == null) { out.startTag(null, "null"); out.endTag(null, "null"); return;/*from w w w . j a v a 2 s.c o m*/ } out.startTag(null, "int-array"); if (name != null) { out.attribute(null, "name", name); } final int N = val.length; out.attribute(null, "num", Integer.toString(N)); for (int i = 0; i < N; i++) { out.startTag(null, "item"); out.attribute(null, "value", Integer.toString(val[i])); out.endTag(null, "item"); } out.endTag(null, "int-array"); }