RSS

Retrieve device information – Android

19 Jan
private void createDeviceInformationFile() throws IOException{
MemoryInfo memoryInfo;
BufferedWriter objBufferedWriter = null;
File objFile;
char[] chrDateFormatOrder;
try{
chrDateFormatOrder = DateFormat.getDateFormatOrder(getApplicationContext());
String strDateFormatOrder = "";

ActivityManager activityManager = (ActivityManager) getApplicationContext().getSystemService(ACTIVITY_SERVICE);
memoryInfo = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);

for (int i = 0; i < chrDateFormatOrder.length; i++) {
strDateFormatOrder = strDateFormatOrder + chrDateFormatOrder[i] + ",";
}

String strDeviceInfo;
strDeviceInfo = "Device Information\n------------------";
strDeviceInfo += "\nBrand: " + Build.BRAND;
strDeviceInfo += "\nDevice: " + Build.DEVICE;
strDeviceInfo += "\nModel: " + Build.MODEL;
strDeviceInfo += "\nId: " + Build.ID;
//Need to add permission related to TelephonyManager in manifest
//strDeviceInfo += "\nDeviceId: " + ((TelephonyManager) getSystemService( Context.TELEPHONY_SERVICE )).getDeviceId();
strDeviceInfo += "\nProduct: " + Build.PRODUCT;
strDeviceInfo += "\nManufacturer: " + Build.MANUFACTURER;
strDeviceInfo += "\nDisplay: " + Build.DISPLAY;
strDeviceInfo += "\nHardware: " + Build.HARDWARE;
strDeviceInfo += "\nBoard: " + Build.BOARD;
strDeviceInfo += "\nFingerprint: " + Build.FINGERPRINT;
strDeviceInfo += "\nBootloader: " + Build.BOOTLOADER;
strDeviceInfo += "\nSerial: " + Build.HOST;
strDeviceInfo += "\nType: " + Build.TYPE;
strDeviceInfo += "\nTime: " + Build.TIME;
strDeviceInfo += "\nTags: " + Build.TAGS;

strDeviceInfo += "\n\nFirmware\n--------";
strDeviceInfo += "\nSDK: " + Build.VERSION.SDK;
strDeviceInfo += "\nRelease: " + Build.VERSION.RELEASE;
strDeviceInfo += "\nIncremental: " + Build.VERSION.INCREMENTAL;

strDeviceInfo += "\n\nInternal Memory\n---------------";
strDeviceInfo += "\nAvailable: " + getAvailableMemory();
strDeviceInfo += "\nTotal: " + getTotalMemory();

strDeviceInfo += "\n\nSD Card Size\n------------";
strDeviceInfo += "\nAvailable: " + getAvailableSDcardMemory();
strDeviceInfo += "\nTotal: " + getTotalSDcardMemory();

strDeviceInfo += "\n\nRAM Specification(MB)\n--------------------";
strDeviceInfo += "\nAvailable: " + memoryInfo.availMem / (1024*1024);
strDeviceInfo += "\nLowMemory: " + memoryInfo.lowMemory;
strDeviceInfo += "\nThreshold: " + memoryInfo.threshold / (1024*1024);

strDeviceInfo += "\n\nTime Zone\n---------";
strDeviceInfo += "\nID: " + (Calendar.getInstance()).getTimeZone().getID().toString() + ", " + "Name: " + (Calendar.getInstance()).getTimeZone().getDisplayName().toString();

strDeviceInfo += "\n\nDate Format\n-----------";
strDeviceInfo += "\nFormat: " + strDateFormatOrder;

objFile = new File("sdcard/deviceInformation.txt");
if(!objFile.exists())
objFile.createNewFile();

//Write to file
objBufferedWriter = new BufferedWriter(new FileWriter(objFile));
objBufferedWriter.write(strDeviceInfo);
}
catch (Exception e) {
e.toString();
}
finally{
memoryInfo = null;
objBufferedWriter.flush();
objBufferedWriter.close();
objFile = null;
chrDateFormatOrder = null;
}
}
Advertisements
 
Leave a comment

Posted by on January 19, 2013 in Android Source Code

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: