Data Recovery and the Three Golden Backups

Our daily lives are tied to the digital world. Where once we had physical photos, CDs, books and files we now generate and buy the virtual equivalents. We store them on our electronic devices and assume that they will last forever in their digital homes, never needing to use data recovery to restore our virtual assets. But do they last forever?

Data Recovery when Computers Breakdown

A home computer can at any time be holding years of personal information and photos. Items that are irreplaceable to you. How long have you had your computer? The older a machine the greater the chance it will breakdown. When it does break you can feel you have lost part of who you are, this can be a scary time especially if you don’t have a backup. Try and stay calm and read this article from Cheeky Munkey about how to recover data from the hard drive within your computer.

data recovery needed

Avoid Hard Drive Data Recovery with Backups

Never get to the point where you need to recover lost files. Most companies that deal with data will have multiple copies of it. Three copies of any file is considered the minimum required. Just as the hip-hop group De La Soul thought that three was The Magic Number you can also use three as the magic number to prevent the need for data recovery.

  1. The original.
  2. A local copy on transportable media (e.g. USB drive, external hard drive).
  3. An off site copy (e.g. cloud storage or on media stored elsewhere, such as a family members house).

Backups are your files insurance policy for when your computer breaks down or is lost. The Internet has made preserving copies of files easier with services like Apple’s iCloud, Microsoft’s OneDrive, Google Drive and Dropbox where saving to a local folder automatically generates a remote copy. But don’t forget your own local copy on portable media. Ultimately the Internet is run by businesses and businesses have been known to shut off services. So remember your three golden backups for all your content.

Grab the Data From a Multiline Android List

Getting the Selected Data from an Android Multiline List

This article shows you how to read the selected data from an Android multiline list. It follows on from the articles Two Line Lists In Android and Multi-Line ListView Entries in Android. Here the selected data is simply shown in a Toast to the user. If you have not got a project ready to use for the following code see the previous tutorials to set up the example State Capitals project in Eclipse.

In the project we used an Activity that extends a ListActivity, this makes available some additional methods to our Activity class. The method getListView() allows us to grab the reference to the ListView which can be used to set the listener which will respond a list item being selected (if you a not familiar with how listeners can be set up in Android see the article Different Ways to Code Android Event Listeners):

[code lang=”Java”]getListView().setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
}
});[/code]

Notice how the click event is given the View that was pressed in the list and the position of the view in the adapter. In our example the adapter was loaded from a string array and hence the postion of the data in the array corresponds to the position in the adapter. Thus position can be used to index into the data array. (If you need to copy this code see Copying Code from the Articles for tips).

[code lang=”Java”]public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
StringBuilder sb = new StringBuilder("Selected:\n");
//By position in array
sb.append(StatesAndCapitals[position][0]+"\n");
sb.append(StatesAndCapitals[position][1]+"\n");
Toast.makeText(StateCapitalsActivity.this, sb.toString(), Toast.LENGTH_LONG).show();
}[/code]

Alternatively the data can be read directly from the TextView within the selected View using the reference passed in to the listener.

[code lang=”Java”]public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
//By finding view id
TextView v=(TextView) view.findViewById(R.id.line_a);
StringBuilder sb = new StringBuilder("Selected:\n");
sb.append(v.getText()+"\n");
v=(TextView) view.findViewById(R.id.line_b);
sb.append(v.getText()+"\n");
Toast.makeText(StateCapitalsActivity.this, sb.toString(), Toast.LENGTH_LONG).show();
}[/code]

The id parameter can also be used to access the data in the adapter for the selected item. In our case the data is stored in a HashMap, but for other implementations using custom adapters another type of object may have been created for use in the adapter, it will depend upon the particular custom implementation.

[code lang=”Java”] public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
//By using data id
StringBuilder sb = new StringBuilder("Selected:\n");
@SuppressWarnings("unchecked")
HashMap<String,String> selected = (HashMap<String,String>) StateCapitalsActivity.this.getListView().getItemAtPosition((int)id);
sb.append(selected.get("line1") + "\n");
sb.append(selected.get("line2") + "\n");
Toast.makeText(StateCapitalsActivity.this, sb.toString(), Toast.LENGTH_LONG).show();
}[/code]

Multiline List Data Access in Android